<?php
$a1 = array("a"=>"red", "b"=>"green", "c"=>"blue", "d"=>"yellow");
$a2 = array("e"=>"red", "f"=>"green", "g"=>"blue");
$result = array_intersect($a1, $a2);
print_r($result); //Array ( [a] => red [b] => green [c] => blue )
<?php
$array1 = array("a" => "verde", "vermelho", "azul");
$array2 = array("b" => "verde", "amarelo", "vermelho");
$result = array_intersect($array1, $array2);
print_r($result); // Array ( [a] => verde [0] => vermelho )
?>
PHP function array_intersect(array $array1, array $array2, array ...$_) int[]
-----------------------------------------------------------------------------
Computes the intersection of arrays
Parameters:
array--$array1--The array with main values to check.
array--$array2--An array to compare values against.
array--...$_--[optional]
Returns: an array containing all of the values in array1 whose values exist in all of the parameters.