note 79261 deleted from control-structures.foreach by felipe

From: Date: Wed, 28 May 2008 12:51:22 +0000
Subject: note 79261 deleted from control-structures.foreach by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139935@lists.php.net to get a copy of this message
Note Submitter: benny-wegner at gmx dot de ---- just discovered a possibility using foreach for iterating ob the original array instead of making a copy: function &wrap(&$a) { return $a; } $myArray = array(1, 2, 3); foreach (test($myArrav) as $myValue) { echo $myValue ." "; // testing the operation on reference by changing $myArray if ($myValue == 3) $myArray []= 4; } prints out: 1 2 3 4

« previous php.notes (#139935) next »