这是我的数组,我要删除键值为60138的数组。如何使用其值删除特定数组?
Array
(
[name] => Hydrangeas.jpg
[keyval] => 23905
)
Array
(
[name] => Chrysanthemum.jpg
[keyval] => 87936
)
Array
(
[name] => Penguins.jpg
[keyval] => 60138
)
Array
(
[name] => Tulips.jpg
[keyval] => 82902
)
谢谢。
答案 0 :(得分:1)
尝试一下:
$array = array(
// here is all your array with name + keyval
);
// Loop throught each array
foreach ($array as $key => $subarray) {
// If keyval has the value you want to delete : remove it from main $array
if ($subarray['keyval'] == 60138) {
unset($array[$key];
}
}