CodeIgniter Forums
how can I generate some array...? - 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: how can I generate some array...? (/showthread.php?tid=41040)



how can I generate some array...? - El Forum - 04-26-2011

[eluser]reka[/eluser]
I have some variable in array..
but I dont know how to generate the result....


here is my code


Code:
$data = array(
'id' => '01',
'name' => 'my name',
'content' => array('one', 'two', 'three')
);
if I generate those code with foreach.. the result is

01my nameArray



any tips..? :roll:


how can I generate some array...? - El Forum - 04-26-2011

[eluser]WanWizard[/eluser]
If you generate what? Some code that produces that result would be handy.

My guess is that you're looping over the array and echoing the value. That's not going to work with array's, you can't echo those (as you have noticed).
So if your array is multi-dimensional, you have to check if the value is an array, and if so, loop over that too...