note 29710 deleted from function.array-slice by didou

From: Date: Fri, 30 Jan 2004 10:28:12 +0000
Subject: note 29710 deleted from function.array-slice by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64426@lists.php.net to get a copy of this message
Note Submitter: j.bailleul@free.fr ---- 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; }

« previous php.notes (#64426) next »