note 57234 deleted from ref.array by aidan

From: Date: Sun, 09 Oct 2005 09:10:51 +0000
Subject: note 57234 deleted from ref.array by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96721@lists.php.net to get a copy of this message
Note Submitter: pol ---- Watch for strange behaviour when trying to delete by value in a integer-only array. For the following function: function my_array_delete_by_value($array, $value) { $array_flip = array_flip($array); if (isset($array[$array_flip[$value]])) unset($array[$array_flip[$value]]); return array_merge($array); } array(4) { [0]=> int(2) [1]=> int(5) [2]=> int(6) [3]=> int(8) } returns array(2) { [0]=> int(5) [1]=> int(8) } ie deletes both element 2 and value 2.

« previous php.notes (#96721) next »