<?php
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
?>
Array
(
[1] => blue
)
$a=[1,2,3];
$b=[2,4,6];
$x = array_diff($b,$a);
echo "<pre>";
print_r($x);
PHP function array_diff(array $array1, array $array2, array ...$_) int[]
--------------------------------------------------------------------
Computes the difference of arrays.
Parameters:
array--$array1--The array to compare from
array--$array2--An array to compare against
array--...$_--[optional]
Returns: an array containing all the entries from array1 that are not present in any of the other arrays.
<?php
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
print_r($result);
?>