CodeIgniter Forums
problem passing an array to a view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: problem passing an array to a view (/showthread.php?tid=30497)



problem passing an array to a view - El Forum - 05-17-2010

[eluser]lord_nerevar[/eluser]
Hi all.

in the controller i have $list that is an array with numeric index, and every field is an array too.

for example $list[$i]['name'] in the controller give me the correct field.

I want to print data in the view instead of the controller, but when i pass $list to a view, as explained in the guide, how can i access to the field with a loop? I had to print all the 'name' field of that array but i can't!


problem passing an array to a view - El Forum - 05-17-2010

[eluser]theprodigy[/eluser]
The array being passed from the controller to the view needs to be an associative array, not numerically indexed.


problem passing an array to a view - El Forum - 05-17-2010

[eluser]lord_nerevar[/eluser]
So i am obliged to "insert" the view in the controller.

Thanks!