"Dog","b"=>"Cat","c"=>"Horse"); print_r($a); unset($a[array_search("Cat",$a)]); //array_search("Cat",$a)按元素值傳回鍵名。去除後保持索引 print_r($a"/> "Dog","b"=>"Cat","c"=>"Horse"); print_r($a); unset($a[array_search("Cat",$a)]); //array_search("Cat",$a)按元素值傳回鍵名。去除後保持索引 print_r($a">
依指定元素值移除陣列元素
複製程式碼 程式碼如下:
//移除值為"Cat"的元素
$a=array("a"=>"Dog", "b"=>"Cat","c"=>"Horse");
print_r($a);
unset($a[array_search("Cat",$a)]);//array_search("Cat ",$a)按元素值傳回鍵名。移除後保持索引
print_r($a);
?>