CodeIgniter Forums
View Data Arrays - 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: View Data Arrays (/showthread.php?tid=19391)



View Data Arrays - El Forum - 06-05-2009

[eluser]Unknown[/eluser]
I am loading a view and im sending it an array from a database.

Code:
data = array([0] => array([Body] .......))
$this->load->view("page", $data);

How would the view handle this since you cant use a number at the beginning of a variable??

This is what im trying todo in the view

Code:
echo $0;



View Data Arrays - El Forum - 06-05-2009

[eluser]mddd[/eluser]
Why not prepare the $data so the array keys are not numbers? Like
Code:
$data = $data[0];
$this->load->view('page',$data);

Then you can use the information from the database in the form of $body, etc.


View Data Arrays - El Forum - 06-05-2009

[eluser]Unknown[/eluser]
Yeah thats always an option but I was wandering if the view loader took care of that in any way.


View Data Arrays - El Forum - 06-05-2009

[eluser]TheFuzzy0ne[/eluser]
You cannot have variable names that start with a digit in PHP, so no, you can't do it the way you want to.