note 21178 deleted from function.array-splice by kennyt

From: Date: Mon, 05 Jan 2004 02:42:58 +0000
Subject: note 21178 deleted from function.array-splice by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62927@lists.php.net to get a copy of this message
Note Submitter: brettbeeson@hotmail.com ---- Further to andrei's note on removing an element. Previous code assumes element exists. Instead, try : // Removes an element with $key in $array, if it exists. function array_remove($key,&$array) { if (key_exists($key,$array)) { $key_index = array_keys(array_keys($array), $key); array_splice($array, $key_index[0], 1); } }

« previous php.notes (#62927) next »