note 110631 deleted from control-structures.foreach by googleguy
| From: | googleguy@php.net | Date: | Wed, 14 Nov 2012 22:16:54 +0000 |
| Subject: | note 110631 deleted from control-structures.foreach by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191939@lists.php.net to get a copy of this message | ||
Note Submitter: oxtor
----
/* foreach example 4: multi-dimensional arrays with key*/
$a = array();
$a[0][0] = "a";
$a[0][1] = "b";
$a[1][0] = "y";
$a[1][1] = "z";
foreach ($a as $k1 => $v1) {
foreach ($v1 as $k2 => $v2) {
echo "$k1 $k2 $v2\n";
}
}
/*
result
0 0 a
0 1 b
1 0 y
1 1 z
*/