note 53714 deleted from ref.array by aidan

From: Date: Sun, 09 Oct 2005 09:13:04 +0000
Subject: note 53714 deleted from ref.array by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96730@lists.php.net to get a copy of this message
Note Submitter: spam at afoyi dot com ---- I've been trying to find a clean way of removing an element from the middle of an indexed array and having all the elements above it "fall down" to fill in the gap. There's no array_delete function, only array_(pop|push|shift|unshift). According to the page for array_merge if it is given a single array then it will be re-indexed. Using that information the following simple function does what I wanted: <?php function my_array_delete($array, $item) { if (isset($array[$item])) unset($array[$item]); return array_merge($array); } ?>

« previous php.notes (#96730) next »