I got multidimensional array.
From each subarray, I would like to remove / unset values with price more than 1500.
Array
$item = array(
'phone' => array(
array(
'Item' => 'S5',
'info' => array(
array('seller' => 'John', 'price' => 1800),
array('seller' => 'Mason','price' => 1200),
array('seller' => 'Alex','price' => 1500),
),
),
array(
'Item' => 'iPhone 5',
'info' => array(
array('seller' => 'Depay', 'price' => 1900),
array('seller' => 'David', 'price' => 1450),
array('seller' => 'Daemon', 'price' => 1600),
)
),
),
);
my code:
foreach($item['phone'] as $key =>$price)
{
foreach($price['info'] as $info => $price2 )
{
if ($info['price'] >= 1500)
{
unset($item[$key][$info ]);
}
}
}
Why this code does not work? Can this be done? and if yes... How???
Thanks in advance :-)