Array Intersection - Compare and get common values in arrays

by sabitha 2012-06-05 17:04:55

Array Intersection - Compare and get common values in arrays




array_intersect - This function computes the intersection of arrays. This returns all elements of array1 that also belongs to array2.

$myarr1 = array("a" => "one", "two", "three");
$myarr2 = array("b" => "two", "four", "one");
$res = array_intersect($myarr1, $myarr2);
print_r($res);

will outputs as
one
two
?>

Tagged in:

452
like
0
dislike
0
mail
flag

You must LOGIN to add comments