note 28818 deleted from control-structures.foreach by sniper
| From: | sniper@php.net | Date: | Wed, 08 Oct 2003 04:06:17 +0000 |
| Subject: | note 28818 deleted from control-structures.foreach by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58005@lists.php.net to get a copy of this message | ||
Note Submitter: DONTSPAMME
----
If you have an array where every object is referenciated by two indexes as:
$array[$index1][$index2]="something";
and you wanna do a foreach like this one:
foreach($array as $aux1 => aux2){
echo "$aux1,";
echo "$aux2\n";
}
the result will be something like this:
something1,array
something2,array
...
but if you do this one:
foreach ($array as $aux1=>$aux2){
echo "$aux1,";
foreach($aux2 as $item1=>$item2){
echo "$item1,";
echo "$item2\n";
}
}
You'll get something like:
something1, value11, value21
value12, value22
something2, value11, value21
value12, value22
...
sorry about my really poor english