Re: foreach / unset

From: Date: Sat, 29 Oct 2005 10:06:16 +0000
Subject: Re: foreach / unset
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-224802@lists.php.net to get a copy of this message
Richard Lynch wrote:
Anyway, can you do *this* safely as a DOCUMENTED FEATURE: foreach($array as $k => $v){ if (...) unset($array[$k]); }
Well, somewhere in the said manual it is written that foreach operates on a *copy* of the array, so you should be safe unsetting values in the original array while iterating through the copy. -- Open source PHP code generator for DB operations http://sourceforge.net/projects/bfrcg/

« previous php.general (#224802) next »