note 30881 deleted from function.unset by sniper

From: Date: Mon, 13 Oct 2003 02:28:42 +0000
Subject: note 30881 deleted from function.unset by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58486@lists.php.net to get a copy of this message
Note Submitter: svbev@umail.ru ---- How to delete from an array. Answer to [oseibert at haba-ag dot de]. Unset() completly deletes an entry from the array. If you want the array numeric keys follow in a natural order you can use array_values() also. function deleteKey($array, $keyname, $value) { end($array); $last = key($array); for($i=0; $i<=$last; $i++) { if($array[$i][$keyname] == $value) { unset($array[$i]); } } $newArray = array_values( $array ); return $newArray; }

« previous php.notes (#58486) next »