emulation of foreach with reference

From: Date: Thu, 07 Mar 2002 17:53:18 +0000
Subject: emulation of foreach with reference
Groups: php.general 
Request: Send a blank email to php-general+get-87647@lists.php.net to get a copy of this message
The code below is too weird. I spent 15 min writing it but now works: for(reset($ar),list($k,)=each($ar),$v=&$ar[$k];$k;list($k,)=each($ar),$v=&$ar[$k]){ var_dump($k,$v); $v='ather'.($j+++0); var_dump($k,$v); } The $ar array is generated in this way : for ($i=0;$i<10;$i++){ $ar['foo'.$i] = 'bar'.$i; } Best regards, Andrey Hristov P.S. There is in PHP's ToDo list such feature.

« previous php.general (#87647) next »