Skip to content

Instantly share code, notes, and snippets.

@aradnom
Created February 4, 2015 21:00
Show Gist options
  • Save aradnom/556ad5c89e1e82dfe2ef to your computer and use it in GitHub Desktop.
Save aradnom/556ad5c89e1e82dfe2ef to your computer and use it in GitHub Desktop.
Performs a true array intersection (array_uintersect will keep items in a1 even if they are not present in a2, a3, etc.)
$combined = array_filter($array1, function ($a) use ($array2) {
$found = array_filter($array2, function ($b) use ($a) {
return ((int) $a->ID) === ((int) $b->ID);
});
return !empty($found);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment