$a = array(
array(
'id' => 15,
'name' => 'John',
'color' => 'red',
),
array(
'id' => 22,
'name' => 'Elise',
'color' => 'blue',
),
array(
'id' => 30,
'name' => 'Mark',
'color' => 'red',
),
);
$b = array(
array(
'id' => 15,
'name' => 'Nancy',
'color' => 'black',
),
array(
'id' => 20,
'name' => 'Elise',
'color' => 'blue',
),
array(
'id' => 30,
'name' => 'Mark',
'color' => 'red',
),
array(
'id' => 40,
'name' => 'John',
'color' => 'orange',
),
);
function compare_ids($a, $b)
{
return ((bool)($a['id'] - $b['id']));
}
print_r(array_intersect_uassoc($a, $b, "compare_ids"));