Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #compare #arrays #objects
ADD COMMENT
Topic
Name
6+3 =