Reply to foreach / unset

Your name:

Reply:


Posted by "Richard Lynch" on 10/20/90 11:30

Somewhere in the manual (damned if I can find it now) it says (or used
to say) that you can or can't safely do this:

while (list($k, $v) = each($array)){
if (...) unset($array[$k]);
}

I don't even remember if it's safe or not, but I swear I saw it not
that long ago...

Anyway, can you do *this* safely as a DOCUMENTED FEATURE:

foreach($array as $k => $v){
if (...) unset($array[$k]);
}

I'm sure I could test it and maybe find out if "it works" but is it
documented behaviour I can rely on? I'm sure not finding this in the
manual now that I go looking for it, though I know I saw it there
before.

PS
I'm being dragged kicking and screaming into using this new-fangled
'foreach' thing instead of while/list/each, and I don't really care
for it so far. :-)

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация