JJR512
03-17-2002, 09:11 AM
I've got some code that generates a nested array...an array inside an array, I guess.
The array is like this:
$article = array('0' => array('headline' => 'blah', 'text' => 'blah blah blah'), '1' => array('headline' => 'la', 'text' => 'la la la la'))
...and so on.
I don't know how to work with nested arrays like this. What I want to do is step through $article, for each nested array like '0' and '1', I want to put each value in the array, like the values for headline and text, into another variable like $headline and $text. Then those variables ($headline and $text) will be dumped into a "bits"-type template. I just don't know how to write the looping code so that for each first-level array (the '0' and '1' and so on), each item in the nested array (the 'headline' and 'text' and so on) get put into variables. Can someone please show me how to do that? Thanks!
The array is like this:
$article = array('0' => array('headline' => 'blah', 'text' => 'blah blah blah'), '1' => array('headline' => 'la', 'text' => 'la la la la'))
...and so on.
I don't know how to work with nested arrays like this. What I want to do is step through $article, for each nested array like '0' and '1', I want to put each value in the array, like the values for headline and text, into another variable like $headline and $text. Then those variables ($headline and $text) will be dumped into a "bits"-type template. I just don't know how to write the looping code so that for each first-level array (the '0' and '1' and so on), each item in the nested array (the 'headline' and 'text' and so on) get put into variables. Can someone please show me how to do that? Thanks!