Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created April 1, 2013 18:59
Show Gist options
  • Select an option

  • Save robertbasic/5286894 to your computer and use it in GitHub Desktop.

Select an option

Save robertbasic/5286894 to your computer and use it in GitHub Desktop.
<?php
$arr1 = array('a' => 'foo', 'b' => 'bar', 'c' => array('spam', 'ham'), 'd' => array('baz'));
$arr2 = array('a' => 'foo', 'c' => array('ham'), 'd' => array('baz'));
$result = array_uintersect_assoc($arr1, $arr2, function ($a1, $a2) {
if ($a1 === $a2) {
return 0;
}
return -1;
});
var_dump($result);
/*
array(2) {
'a' =>
string(3) "foo"
'd' =>
array(1) {
[0] =>
string(3) "baz"
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment