我有多维数组,想删除交货位置
Array
(
[0] => Array
(
[amountReceived] => 1
[deliveryLocation] => germany
)
[1] => Array
(
[amountReceived] => 2
[deliveryLocation] => bulgaria
)
)
PHP
foreach ($arr as $val)
{
foreach($val as $k => $v)
{
if($k == 'deliveryLocation')
{
unset($arr[$k]);
}
}
}
return $arr;
问题是它会按原样返回数组上面,而不会从中删除任何键。
答案 0 :(得分:0)
易于理解的方式
$t=0;
foreach ($arr as $val)
{
unset($arr[$temp]['deliveryLocation']);
$t++;
}