note 24973 added to control-structures.foreach

From: Date: Fri, 06 Sep 2002 12:09:12 +0000
Subject: note 24973 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-36239@lists.php.net to get a copy of this message
It seams that foreach compute len of the array at the begining of the loop. ------------------------------ foreach($tab as $item){ echo "$item:"; if($item=="b"){ $tab[2]="-"; $tab[]="d"; } for($i=0;$i<=4;$i++)echo $tab[$i].","; echo "\n"; } ---------OUTPUT---------------- a: a , b , c b: a , b , - , d c: a , b , - , d ------------------------------- It doesn't do the loop for "d" ... too bad :-( -- http://www.php.net/manual/en/control-structures.foreach.php http://master.php.net/manage/user-notes.php?action=edit+24973 http://master.php.net/manage/user-notes.php?action=delete+24973 http://master.php.net/manage/user-notes.php?action=reject+24973

« previous php.notes (#36239) next »