note 28818 added to control-structures.foreach

From: Date: Fri, 24 Jan 2003 20:20:46 +0000
Subject: note 28818 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-42704@lists.php.net to get a copy of this message
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 -- http://www.php.net/manual/en/control-structures.foreach.php http://master.php.net/manage/user-notes.php?action=edit+28818 http://master.php.net/manage/user-notes.php?action=delete+28818 http://master.php.net/manage/user-notes.php?action=reject+28818

« previous php.notes (#42704) next »