Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created February 8, 2017 16:27
Show Gist options
  • Save ccapndave/7b5ba62b333d22eb4f1dd174a89f04d5 to your computer and use it in GitHub Desktop.
Save ccapndave/7b5ba62b333d22eb4f1dd174a89f04d5 to your computer and use it in GitHub Desktop.
// A very ugly PHP way of removing duplicates from an array with regard to strict equality
$users = (function(...$arrays) {
$uniqueElements = [];
foreach ($arrays as $array) {
foreach ($array as $element) {
$uniqueElements[spl_object_hash($element)] = $element;
}
}
return array_values($uniqueElements);
})($array1, $array2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment