note 39619 deleted from function.unset by didou

From: Date: Thu, 05 Feb 2004 09:24:03 +0000
Subject: note 39619 deleted from function.unset by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64674@lists.php.net to get a copy of this message
Note Submitter: Moharo@hotmail.com ---- to use unset() in a loop in order to delete some elements from the array, do the following: for($i=0,$size=sizeof($array_name);$i<$size;$i++) { if($array_name[$i] == 0) { //delete elements containing 0 unset($array_name[$i]); } } if unset() is called in a loop, the array length is changed.

« previous php.notes (#64674) next »