Created
September 18, 2010 21:17
-
-
Save xeoncross/586042 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$array_1 = array('zero', 'two', 'three', 'five'); | |
$array_2 = array('one', 'three', 'four','six','eight', 'nine'); | |
$array_3 = array('one', 'four', 'five', 'six','seven', 'eight'); | |
$array_4 = array('zero', 'four', 'five', 'eight', 'nine'); | |
// All elements missing from one array that are present in the other | |
function array_diff2($a,$b) | |
{ | |
return array_diff(array_merge($a,$b),array_intersect($a,$b)); | |
} | |
// Elements missing from $a, that are present in every other array | |
function array_missing($a,$b,$c ='$d,$e,etc..') | |
{ | |
$a=array_diff($b,$a);foreach(array_slice(func_get_args(),2)as$c)$a=array_intersect($a,$c);return$a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment