If you want to get all those values which exist in an array and also exist in other array means intersect values between an array and the set of other arrays then you can use a predefined php function array_intersect. array_intersect() returns an array containing all the values of array1 that are present in all the arguments.
Note that keys are preserved.
array_intersect returns an array containing all of the values in array1 whose values exist in all of the parameters.
Here are a example which will explain array_intersect()-
<?php
$array1 = array("a" => "green", "red", "blue");
$array2 = array("b" => "green", "yellow", "red");
$result = array_intersect($array1, $array2);
print_r($result);
?>
Output:
Array
(
[a] => green
[0] => red
)
0 Comment(s)