CodeIgniter Forums
associative arrays - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: associative arrays (/showthread.php?tid=35344)



associative arrays - El Forum - 10-26-2010

[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


associative arrays - El Forum - 10-26-2010

[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;
}



associative arrays - El Forum - 10-26-2010

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

Thank you very much

fmm