Welcome Guest, Not a member yet? Register   Sign In
associative arrays
#1

[eluser]Unknown[/eluser]
Good evening,

I am a New comer in CodeIgniter and have some issues when passing parameters to the views.

I am trying to pass 20 random numbers to "views" and it looks it doesn't work because I need an associative array. Moreover in the "view", I use a foreach loop what definitely doesn't work.

Does someone knows how to pass a simple table (non associative) and display it in the views ?

Thanks

fmm
#2

[eluser]WanWizard[/eluser]
The parameter is always an associative array.
Code:
$random = array(1,6,3,8,3,6,7);
$data['random'] = $random;
$this->load->view('myview', $data);

You can then iterate over it in the view
Code:
foreach ( $random as $value )
{
     echo $value;
}
#3

[eluser]Unknown[/eluser]
:-) excellent :-)

Thank you very much

fmm




Theme © iAndrew 2016 - Forum software by © MyBB