Hi Astions, thank you for taking your time with this

astions wrote:Note: Unless the array is referenced, foreach operates on a copy of the specified array and not the array itself. foreach has some side effects on the array pointer. Don't rely on the array pointer during or after the foreach without resetting it.
http://us3.php.net/manual/en/control-st ... oreach.php
"
foreach has some side effects on the array pointer. Don't rely on the array pointer during or after the foreach without resetting it."
I find this piece of the sentence a little disturbing. And the whole sentence starts with "
Unless the array is referenced..", so I'm not sure if they mean the internal pointer in an unreferenced or referenced foreach. It doesn't state what are the side effects, and to what degree we can actually trust a referenced foreach. But I clearly get the message that one might experience some smelly fish while doing unordinary things in a referenced foreach loop.
astions wrote:
$value is not referenced to $array[%n] and even if it was $array[%n] would be a copy of the original. Why would you expect that to work? Additionally, even if you were working with a referenced copy, the manual states that changing the content of an array while your iterating it with a foreach loop can lead to unpredictable results.
Now I'm confused. $value
is not a reference to an arrays values in a foreach loop?? I thought that was the point of &$value.. I couldn't find anywhere in the foreach manual that stated that changing the content of an array while foreach-ing it can lead to unpredictable results (maby you mean somewhere else, or in the comments? ..didn't read all of them)
VladSun wrote:Sorry, couldn't reproduce it.
And yes - I should have read the rest of the page I pointed to

That reply might be the one that cleared things up a little bit. It, and the fact that I am useing
PHP 5.2.0-8+etch11 myself, got me into searching the changelog for more answers. I think I found something in this one:
Bug #35106: nested foreach fails when array variable has a reference
http://bugs.php.net/bug.php?id=35106
The scenario described is not exactly the same as mine, but it certainly resembles it. And considering that this bug was fixed between v5.2.0 and v5.2.1, it might be
the fix that makes your (Vlads) results differ from mine. I suspect you have a typo with the c value being 2 and not 1 though?
To conclude: It's seems the suspicious behavior I was experiencing in fact was a bug, that has now been fixed with PHP versions >= 5.2.1
