note 27103 deleted from function.array-splice by felipe

From: Date: Sat, 05 Jan 2008 02:07:57 +0000
Subject: note 27103 deleted from function.array-splice by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134811@lists.php.net to get a copy of this message
Note Submitter: richard at richard-sumilang dot com ---- 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; } ?>

« previous php.notes (#134811) next »