Last active
May 18, 2018 13:28
-
-
Save marek-saji/c2d8af3df7edc66297d4c5643918d598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array1 = array( | |
array('A', 1), | |
array('B', 1), | |
); | |
$array2 = array( | |
array('A', 2), | |
array('C', 2), | |
); | |
// http://devdocs.io/php/function.array-udiff | |
// Returns an array containing all the values of array1 that are not | |
// present in any of the other arguments. | |
$DIFF = array_udiff( | |
$array1, | |
$array2, | |
function ($a, $b) { | |
// The comparison function must return an integer less than, | |
// equal to, or greater than zero if the first argument is | |
// considered to be respectively less than, equal to, or greater | |
// than the second. | |
return $a[0] === $b[0] ? 0 : 1; | |
} | |
); | |
var_dump($DIFF); // Would expect to get array(array('A', 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment