There is diff_array that will compare the values ββof 2 arrays and return an array with the difference values.
$arrayone = array("bacon" => "tasty", "lettuce", "carrot"); $arraytwo = array("ham" => "tasty", "carrot"); $differences = array_diff($arrayone, $arraytwo); var_dump($differences); $differences = array_diff($arraytwo, $arrayone); var_dump($differences);
This will give:
array (size=1) 0 => string 'lettuce' (length=7) array (size=0) empty
One important thing is only that the first array is compared with other passed ones.
http://php.net/manual/en/function.array-diff.php
source share