Re: bug when using foreach with references?

From: Date: Thu, 22 Oct 2009 16:49:12 +0000
Subject: Re: bug when using foreach with references?
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-45871@lists.php.net to get a copy of this message
It is one of these things that make perfect sense when you think about it a little bit. Yes, it catches some people, just like strpos() returning character position 0 on a first-char match catches some people. There is no way to fix things like these without completely breaking things. If we had strpos not use 0-based string positions or if we arbitrarily broke references after loops, all sorts of other things would start breaking and no longer make sense. -Rasmus
Rasmus, Thanks for your reply. With respect, this seems to be in a different class from matching strings with character position 0, IMO. What about unsetting the iterator before foreach() looping begins? The iterator is altered anyway, so would this prevent it from being "attached" to previous foreach() iterations? Best, Richard

« previous php.internals (#45871) next »