douqi1931 2015-04-22 15:58
浏览 43

如何以给定格式在会话数组中存储数据?

Category Name
  List A = Rm 20
  List B = Rm 50

Category Name
  List A = Rm 40

category Name
  List A = Rm 80
  List B = Rm 40
  List C = Rm 25

I tried

$_SESSION['info']=array('category'=>$category,'list'=>$list,'rate'=>$rate);

But it doesn't display as the format wanted. Can anyone help please?`

EDIT:

I think I didn't elaborate clearly.

The values for item category, list and rate come from user input.

SO I store them in variables like this:

php

$category[]=$_POST['category'];<br/>
$list[]=$_POST['list'];
$rate[]=$_POST['rate'];

storing in session array like this:

$_SESSION['info']]=array('level'=>$level,'subject'=>$subject2,'rate'=>$rate2);`

html

<input type="checkbox" name="category['category name']" id="category" class=category" value="1">

<input type="checkbox" name="list['category name']" id="list" value="'List id'">

<input type="textbox" name="rate['List name']" class="rate" value="" id="'List Name'">
  • 写回答

1条回答 默认 最新

  • duansha3771 2015-04-22 16:05
    关注

    Try the following:

    $_SESSION['info'] = Array(
        'Category Name' => Array(
            'List A' => 'Rm 20', // don't forget "," if you're adding additional item.
            'List B' => 'Rm 50'
        ), 
        'Category Name' => Array(
            'List A' => 'Rm 40'
        )
        // Etc..
    );  
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100