[PHP] emulation of foreach with reference

2002-03-07 Thread Andrey Hristov
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

Re: [PHP] emulation of foreach with reference

2002-03-07 Thread Andrey Hristov
try this: ?php echo foo.$i++; echo \n; echo bar.($+++0); ? Thanks for showing that I add new element to the array. This is because on last iteration $k is null and I access $ar[$k] which automatically adds the new element. Why? I don't know? Maybe because I refer it by reference! The fixed

Re: [PHP] emulation of foreach with reference

2002-03-07 Thread Andrey Hristov
ooops ?php echo foo.$i++; echo \n; echo bar.($j+++0); ? On Thursday 07 March 2002 09:09 pm, Andrey Hristov wrote: try this: ?php echo foo.$i++; echo \n; echo bar.($+++0); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: