note 16963 deleted from function.array-slice by jimw

From: Date: Mon, 10 Dec 2001 23:29:22 +0000
Subject: note 16963 deleted from function.array-slice by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22462@lists.php.net to get a copy of this message
Someone above wrote a function for removing one single element from an array. It is too slow for my purposes, instead just write this one line: $myarray = array_merge(array_slice($myarray,0,$i),array_slice($myarray,$i+1)); It completely removes element number $i from the array $myarray - the elements with higher numbers will be shunted down one. (NB - just using unset() leaves an empty array element and doesn't 'shunt'.)

« previous php.notes (#22462) next »