I have an array that contains this items (content):
Array
(
[0] => Array
(
[id] => 53
)
[1] => Array
(
[id] => 54
)
[2] => Array
(
[id] => 60
)
)
I want to remove all the items that have a specific id available in another array, like: $to_remove = ["53", "54", "60"], what I did is:
foreach($to_remove as $id)
{
$key = array_search($id, array_column($content, 'id'));
unset($content[$key]);
}
the problem is that in the final result I have:
Array
(
[2] => Array
(
[answer] => >20%
[points] => 3
[id] => 60
)
)
why?
2instead of0, or why the element withid => 60is still in the array even though it should have been removed?