note 2475 modified in each by ronabop
| From: | ronabop@php.net | Date: | Mon, 21 Aug 2000 09:42:32 +0000 |
| Subject: | note 2475 modified in each by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-2859@lists.php.net to get a copy of this message | ||
Traversing multidimensional arrays is
easy, especially if you know how many dimensions are involved. Suppose you have a structure returned
from a database query, such as
$returned_rows[$row_number][$field_name]
To walk through each field, you
might try this:
while (
list($row_number, $row_array)
= each($query_result_array)
) {
while (
list($field_name, $field_value)
= each($row_array)
) {
##
## $row_number has the
## current row number,
## $field_name hsa the current
## field' name,
## $field_value has the current ## field's value
}
}
}
http://www.php.net/manual/function.each.php