Welcome Guest, Not a member yet? Register   Sign In
View Data Arrays
#1

[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;
#2

[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.
#3

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB