On Friday, February 17, 2012 11:00:36 Mars wrote: > Hello everybody. > Once again I have a little question, this time about removing > items from an assoc array in a foreach. > > Why does the following code: > http://pastebin.com/65P9WDNS > Result in this output: > http://pastebin.com/4FzEE1zi > > It seems rather strange to me. I'd expect the foreach_reverse to > go over the array from the end to the beginning, and when I > remove stuff from it, it shouldn't be a problem. But apparently > it is.
I don't believe that removing elements from an AA while iterating over it is safe. - Jonathan M Davis