2 dimensional array processing
| From: | Benjamin Edwards | Date: | Tue, 11 Jan 2005 11:22:57 +0000 |
| Subject: | 2 dimensional array processing | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-206067@lists.php.net to get a copy of this message | ||
If I create the following 2 dimensional associative array:-
$insert["tab2"]["fields1"] = "value1";
$insert["tab1"]["fields2"] = "value2";
$insert["tab2"]["fields5"] = "value3";
$insert["tab1"]["fields7"] = "value4";
how do I do 2 levels of nested loop with the first level looping through the first level of the
array and the second nesting through the second. something like:-
foreach( $insert as $table => $fields ) {
foreatch( $fields as $field => $value ) {
echo "update $table set $field = $value";
}
}
Regards,
Ben