I have two arrays and I need remove from bigger array smaller
$a = array(223 => 6, 381 => 6);
and second arrays is:
$b = array(array('id' => 45, 'username' => 'rock'), array('id' => 223, 'username' => 'pop'), array('id' => 381, 'username' => 'stock'));
With print_r() they looks like this
Array
(
[223] => 6
[381] => 6
)
Array
(
[0] => Array
(
[id] => 45
[username] => rock
)
[1] => Array
(
[id] => 223
[username] => pop
)
[2] => Array
(
[id] => 381
[username] => stock
)
)
How do I remove from $b array where id != $a[keys] So in result I will have array like this
Array
(
[0] => Array
(
[id] => 223
[username] => pop
)
[1] => Array
(
[id] => 381
[username] => stock
)
)
I try to use array_diff, array_search and unset but do not know how make it work.