note 30881 added to function.unset

From: Date: Wed, 02 Apr 2003 08:18:53 +0000
Subject: note 30881 added to function.unset
Groups: php.notes 
Request: Send a blank email to php-notes+get-46106@lists.php.net to get a copy of this message
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; } -- http://www.php.net/manual/en/function.unset.php http://master.php.net/manage/user-notes.php?action=edit+30881 http://master.php.net/manage/user-notes.php?action=delete+30881 http://master.php.net/manage/user-notes.php?action=reject+30881

« previous php.notes (#46106) next »