![]() |
Multidimensional array read-out in view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multidimensional array read-out in view (/showthread.php?tid=2546) |
Multidimensional array read-out in view - El Forum - 08-11-2007 [eluser]Unknown[/eluser] When I output print_r($data); I get: Code: Array My question is, how do I access [0] and [1] and put them in a loop? Multidimensional array read-out in view - El Forum - 08-12-2007 [eluser]Michael Wales[/eluser] CI automatically brings the var array to the top level - I've never dove into the code to see why. So, you should be able to loop through those arrays like so: Code: foreach ($0 as $key => $val) { If that doesn't work for you just change $0 and $1 to $vars[0] and $vars[1], respectively. Multidimensional array read-out in view - El Forum - 08-12-2007 [eluser]Unknown[/eluser] I belive you want to have a multidimensional foreach loop that loops the numbers to, like: Code: foreach($var as $key => $val) { Code: 0 So you have to make sure you pass the vars to the view something like this: Code: [vars] => Array |