我有多维数组,想要在存在的地方删除交货位置
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;
问题是它在数组上方返回,因为它没有从中删除任何键。
易于理解的方式
$t=0;
foreach ($arr as $val)
{
unset($arr[$temp]['deliveryLocation']);
$t++;
}