// Computes the difference of arrays by using a callback function for data comparison. This is unlike array_diff() which uses an internal function for comparing the data.
function compare_objects($obj_a, $obj_b) {
return $obj_a->id - $obj_b->id;
}
$diff = array_udiff($first_array, $second_array, 'compare_objects');