note 29710 added to function.array-slice

From: Date: Sat, 22 Feb 2003 17:09:12 +0000
Subject: note 29710 added to function.array-slice
Groups: php.notes 
Request: Send a blank email to php-notes+get-44349@lists.php.net to get a copy of this message
This is a fonction to remove one element. Combine array_slice and array_merge function remove_one_element($array,$index_to_remove){ //$index_to_remove : type integer $index_nb_elements=count($array)-1; switch($index_to_remove){ case 0: $array = array_slice($array, 1); break; case $index_nb_elements : $array = array_slice($array, -1); break; default: $array_start = array_slice($array,0, $index_to_remove); $array_end = array_slice($array, $index_to_remove+1); $array = array_merge ($array_start, $array_end); break; } return $array; } -- http://www.php.net/manual/en/function.array-slice.php http://master.php.net/manage/user-notes.php?action=edit+29710 http://master.php.net/manage/user-notes.php?action=delete+29710 http://master.php.net/manage/user-notes.php?action=reject+29710

« previous php.notes (#44349) next »