RE: [PHP] traverse a multidimensional array
| From: | Boget, Chris | Date: | Thu, 20 Jul 2000 14:02:35 +0000 |
| Subject: | RE: [PHP] traverse a multidimensional array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-7417@lists.php.net to get a copy of this message | ||
> > How do I list the contents of each "second level" array? (not
> > sure of the correct terms)
> Same as you did the first:
> while(list($key,$value)=each($arrResult)) {
> echo "array[$key]=$value<br>\n";
> while( list( $key2, $value2 ) = each( $value )) {
> echo "$key2 = $value2<br>\n";
>
> }
> }
Or, if the second array is not multi-dimensional, change
the embedded loop to:
for( $i = 0; $i < count( $value ); $i++ ) {
Chris