note 73572 added to function.array-slice

From: Date: Thu, 01 Mar 2007 21:43:29 +0000
Subject: note 73572 added to function.array-slice
Groups: php.notes 
Request: Send a blank email to php-notes+get-123996@lists.php.net to get a copy of this message
/** * Remove a value from a array * @param string $val * @param array $arr * @return array $array_remval */ function array_remval($val, &$arr) { $array_remval = $arr; for($x=0;$x<count($array_remval);$x++) { $i=array_search($val,$array_remval); if (is_numeric($i)) { $array_temp = array_slice($array_remval, 0, $i ); $array_temp2 = array_slice($array_remval, $i+1, count($array_remval)-1 ); $array_remval = array_merge($array_temp, $array_temp2); } } return $array_remval; } $stack=Array('apple','banana','pear','apple', 'cherry', 'apple'); array_remval("apple", $stack); //output: Array('banana','pear', 'cherry') ---- Server IP: 69.147.83.197 Probable Submitter: 201.80.162.156 ---- Manual Page -- http://www.php.net/manual/en/function.array-slice.php Edit -- https://master.php.net/note/edit/73572 Del: integrated -- https://master.php.net/note/delete/73572/integrated Del: useless -- https://master.php.net/note/delete/73572/useless Del: bad code -- https://master.php.net/note/delete/73572/bad+code Del: spam -- https://master.php.net/note/delete/73572/spam Del: non-english -- https://master.php.net/note/delete/73572/non-english Del: in docs -- https://master.php.net/note/delete/73572/in+docs Del: other reasons-- https://master.php.net/note/delete/73572 Reject -- https://master.php.net/note/reject/73572 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123996) next »