Answers for "php compare two arrays of objects"

PHP
0

php compare two arrays of objects

// 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');
Posted by: Guest on August-16-2021

Code answers related to "php compare two arrays of objects"

Browse Popular Code Answers by Language