note 86191 added to function.array-slice
| From: | businesscatalyst dot com at osu1 dot php dot net | Date: | Tue, 07 Oct 2008 14:32:25 +0000 |
| Subject: | note 86191 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145127@lists.php.net to get a copy of this message | ||
I tried the arem function provided below and found that when the keys are numeric, a slight
modification needs to be made to keep the returned array indices continuous. Here's my update:
#Remove an element from an array and return the result
function arem($array,$value){
$holding=array();
foreach($array as $k => $v){
if($value!==$v){ //when comparing strings, !== is appropriate here instead of !=
$holding[]=$v; //removed the key so continuous indexes are preserved. Put $k back in if
the keys need to be preserved.
}
}
return $holding;
}
----
Server IP: 64.71.164.2
Probable Submitter: 75.131.167.255
----
Manual Page -- http://www.php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/86191
Del: integrated -- https://master.php.net/note/delete/86191/integrated
Del: useless -- https://master.php.net/note/delete/86191/useless
Del: bad code -- https://master.php.net/note/delete/86191/bad+code
Del: spam -- https://master.php.net/note/delete/86191/spam
Del: non-english -- https://master.php.net/note/delete/86191/non-english
Del: in docs -- https://master.php.net/note/delete/86191/in+docs
Del: other reasons-- https://master.php.net/note/delete/86191
Reject -- https://master.php.net/note/reject/86191
Search -- https://master.php.net/manage/user-notes.php