Welcome Guest, Not a member yet? Register   Sign In
How to send a array to the view[SOLVED]
#1

[eluser]Peter74[/eluser]
I have this Array (a lot of items more)

Code:
Array $budies look like this
Array ( [0] => 826 [1] => 019 [2] => 823 [3] => 139 [4])
Code:
$this->load->view('allbudies' , $budies);
i dont know how to pass it to the view

How i can retrieve that information? (foreach I think)
But i dont know how.

Txs in advance

Code:
$consulta['friends'] = $this->facebook->api_client->friends_get();  
$this->load->view('welcome_message' , $consulta);
#2

[eluser]jdfwarrior[/eluser]
Once you pass an array to the view, you can access it within the array by the index. They are automatically converted to individual variables for you. For instance if you made this array:

Code:
$data = array(
'page_title'=>'This is the page title',
'author_name'=>'Your name here',
);

Then you could access that data in the view by $page_title and $author_name.

You would use a foreach if you have a nested array, like:

Code:
$data = array(
'page_title'=>'This is the page title',
'author_name'=>'Your name here',
);

$second = array(
'temp'=>'test',
'values'=>$data
);

Then you could use foreach to iterate through the $values array

Hope this helps




Theme © iAndrew 2016 - Forum software by © MyBB