note 103162 added to function.array-slice

From: Date: Tue, 29 Mar 2011 18:38:15 +0000
Subject: note 103162 added to function.array-slice
Groups: php.notes 
Request: Send a blank email to php-notes+get-178311@lists.php.net to get a copy of this message
If you want to remove a specified entry from an array i made this mwethod... <?php $array = array("Entry1","entry2","entry3"); $int = 3; //Number of entries in the array $int2 = 0; //Starter array spot... it will begine its search at 0. $del_num = 1; //Represents the second entry in the array... which is the one we will happen to remove this time... i.e. 0 = first entry, 1 = second entry, 2 = third........... $newarray = array(); //Empty array that will be the new array minus the specified entry... print_r($array) . "<br>"; //print original array contents print_r($newarray). "<br>"; //print the new empty array do { $user = $array[$int2]; $key = array_search($user, $array); if ($key == $del_num) { } else { $newarray[] = $array[$int2]; } $int2 = $int2 + 1; } while ($int2 < $int); print_r($newarray). "<br>"; //print the new array ?> ---- Server IP: 69.147.83.197 Probable Submitter: 97.119.10.52 ---- Manual Page -- http://www.php.net/manual/en/function.array-slice.php Edit -- https://master.php.net/note/edit/103162 Del: integrated -- https://master.php.net/note/delete/103162/integrated Del: useless -- https://master.php.net/note/delete/103162/useless Del: bad code -- https://master.php.net/note/delete/103162/bad+code Del: spam -- https://master.php.net/note/delete/103162/spam Del: non-english -- https://master.php.net/note/delete/103162/non-english Del: in docs -- https://master.php.net/note/delete/103162/in+docs Del: other reasons-- https://master.php.net/note/delete/103162 Reject -- https://master.php.net/note/reject/103162 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178311) next »