I have two arrays.
I have a foreach loop which is iterating through one of these arrays ($items). For each value in this array, if a condition is not true, I would like to unset that same key, but from another, similar array ($list). (The two arrays are not identical, but the key will always be the same).
I am unsure how to go about this. The code I used below did not successfully unset the record from the first array.
Both arrays do have keys (IDs), with secondary data.
$list = array(
'id' => '2',
'id' => '3',
'id' => '4',
'id' => '5',
'id' => '6'
);
$items = array(
'id' => '2',
'id' => '3',
'id' => '4',
'id' => '5',
'id' => '6'
);
foreach ($items AS $key => $item)
{
if ($item['id'] != $setting)
{
unset($list[$key]);
}
}