php - How to store data inside session array in given format? -
category name list = rm 20 list b = rm 50 category name list = rm 40 category name list = rm 80 list b = rm 40 list c = rm 25
i tried
$_session['info']=array('category'=>$category,'list'=>$list,'rate'=>$rate);
but doesn't display format wanted. can please?`
edit:
i think didn't elaborate clearly.
the values item category, list , rate come user input.
so store them in variables this:
php
$category[]=$_post['category'];<br/> $list[]=$_post['list']; $rate[]=$_post['rate'];
storing in session array 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'">
try 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.. );
Comments
Post a Comment