CI Session Array Problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: CI Session Array Problem (/showthread.php?tid=35525) |
CI Session Array Problem - El Forum - 11-02-2010 [eluser]mohsin917[/eluser] Hi. This is the thing that i do in simple code. Every time when this code runs it create new index of basket in session array and when i want to get data i just do it with simple loop. Now i want to do it in CI using session class Code: $product_array = array( simply array is working in CI Session class. But can't add the session auto incremented array. Even i also try to do this. Code: $basket[] = array( but not helpful. Any idea?? CI Session Array Problem - El Forum - 11-02-2010 [eluser]nggakbiasa[/eluser] try : Code: $basket = array("basket" => CI Session Array Problem - El Forum - 11-02-2010 [eluser]mohsin917[/eluser] No its not working. Problem is not assigning the values to array. Problem is how to automatically increase the index value of array: Like: Code: for($x = 0; $x < 10; $x++) now the $ary has 10 indexes with different values. How to implement it into the session class of CI.. If there is no solution I have to use the simple code that i described already CI Session Array Problem - El Forum - 11-02-2010 [eluser]nggakbiasa[/eluser] sorry, i don't get what you mean. This is the output when i do "print_r" on $this->session->userdata Code: [basket] => Array to add more i do : Code: $basket['basket'] []=array( is it something like that ? CI Session Array Problem - El Forum - 11-02-2010 [eluser]mohsin917[/eluser] Well very close suggestion. Appreciate for help. but not working as i am expecting. The new working code is Code: $basket['basket'][0] = array( Problem is i have to check how many indexes of $basket['basket'][] is registered and when control goes through the above code again then make 1+. Actually $basket['basket'][] this should add another index automatically. Don't understand why it isn't. CI Session Array Problem - El Forum - 11-02-2010 [eluser]smilie[/eluser] Hm, I could be completely wrong on this one as I do not grasp the array's fully myself - but; Is it possible that your code 'overwrites' the array? Meaning - when you store new array values, the old ones get replaced? Could you try: Code: # New basket array: Cheers, Smilie |