note 26760 deleted from control-structures.foreach by sniper

From: Date: Wed, 08 Oct 2003 04:07:09 +0000
Subject: note 26760 deleted from control-structures.foreach by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58008@lists.php.net to get a copy of this message
Note Submitter: gideon@fmf.nl ---- I found it impossible to edit values of references like this: $een = 1; $twee = 2; $drie = 3; $lst = array(&$een, &$twee, &$drie); foreach ($lst as $c) $c += 10; foreach ($lst as $c) echo("$c \n"); this gives "1 2 3" not "11 12 13" as i would have liked it to I think this has to do with 'foreach' working on a copy of the array.. Besides "foreach ($lst as &$c)" won't work either.. it isn't accepted by the php parser. The best solution to handle this array of references is with a while loop.

« previous php.notes (#58008) next »