note 40024 deleted from function.array-splice by felipe
| From: | felipe@php.net | Date: | Sat, 05 Jan 2008 02:08:33 +0000 |
| Subject: | note 40024 deleted from function.array-splice by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134817@lists.php.net to get a copy of this message | ||
Note Submitter: bitmor.co.kr
----
//orginal
IndexKey Bad Police
richard at richard-sumilang dot com
23-Nov-2002 04:27
<?php
function array_slice2($array, $val, $slice="name"){
switch($slice){
case "name":
while(list($i,$k)=each($array)){
if( $i != $val) { $return[$i]=$array[$i]; print "i = $i,val = $val<br>";}
else print " exit BugShow i = $i,val = $val <br>";
}
break;
case "variable":
while(list($i)=each($array)){
if($array[$i]!=$val) $return[$i]=$array[$i];
}
break;
}
return $return;
}
$list = array( "0" => "zero", "1" => "one",
"2" => "two", "3" => "three", "4" =>
"four", "5" => "five", "6" => "six");
print_r( array_slice2 ( $list,'tne') );echo "<br>";
//YouWantShow ? Array ( [0] => zero [1] => one [2] => two [3] => three [4] =>
four [5] => five [6] => six )
//But BugShow ? Array ( [1] => one [2] => two [3] => three [4] => four [5] =>
five [6] => six )
//PrintShow
//exit BugShow i = 0,val = tne
//i = 1,val = tne
//i = 2,val = tne
//i = 3,val = tne
//i = 4,val = tne
//i = 5,val = tne
//i = 6,val = tne
?>
<?php
print_r( array_slice2 ( $list,"one","variable") );echo "<br>";
//Array ( [0] => zero [2] => two [3] => three [4] => four [5] => five [6] => six
)
?>
//