note 33614 rejected from ref.array by philip

From: Date: Sat, 05 Jul 2003 17:00:08 +0000
Subject: note 33614 rejected from ref.array by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-51556@lists.php.net to get a copy of this message
Note Submitter: Jonas Lindeløv ---- A function to remove a row from an array... I couldn't find it in the function list above, or contributed by any users, so here it is: // Function requires two arguments: The array you want to remove a row from, and the index of the row. function deleterow($array, $index) { for($i=0; $i<$index; $i++) { $temp[$i] = $array[$i]; } for($i=$index+1; $i<count($array); $i++) { $temp[$i-1] = $array[$i]; } return $temp; } //Use of function - this will remove the second row: $somearray = deleterow($somearray, 1); Please note that this functon is as simple as can be, and therefore have no checking. If you put in an index number larger than the actual number of rows in the array or <0, the function will add rows to the array.

« previous php.notes (#51556) next »