Intersecting two arrays that have no duplicate keys, all the keys will be retained. : array_intersect « Data Structure « PHP






Intersecting two arrays that have no duplicate keys, all the keys will be retained.

 
<?
    $arr1 = array("Paul"=>25, "Ildiko"=>38, "Nick"=>27);
    $arr2 = array("Ildiko"=>27, "Paul"=>38);

    print "\nIntersect:\n";
    var_dump(array_intersect($arr1, $arr2));
?>
  
  








Related examples in the same category

1.Array Intersection
2.array_intersect
3.array_intersect( ) function returns a new array containing all the values of array $arr1 that exist in array $arr2.
4.array_intersect_assoc