note 27103 added to function.array-splice
| From: | richard at richard-sumilang dot com | Date: | Fri, 22 Nov 2002 20:27:55 +0000 |
| Subject: | note 27103 added to function.array-splice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39876@lists.php.net to get a copy of this message | ||
My function can remove it by its name or if its equal to something. Became useful because I was
inserting all the stuff from the post array into the database but the damn submit button kept
comming up with the $_POST also so I wrote this function to get rid of it.
-------------------------------------
<?
/*
func.array_slice2.php
Removes a slice from an array given the name of
it or the value
Ex:
$array=array_slice2($_POST, "submit_button");
*/
function array_slice2($array, $val, $slice="name"){
switch($slice){
case "name":
while(list($i)=each($array)){
if($i!=$val){
$return[$i]=$array[$i];
}
}
break;
case "variable":
while(list($i)=each($array)){
if($array[$i]!=$val){
$return[$i]=$array[$i];
}
}
break;
}
return $return;
}
?>
--
http://www.php.net/manual/en/function.array-splice.php
http://master.php.net/manage/user-notes.php?action=edit+27103
http://master.php.net/manage/user-notes.php?action=delete+27103
http://master.php.net/manage/user-notes.php?action=reject+27103