array_intersect_key

It finds the intersection of arrays using keys for comparison

Example

<?php
echo “<pre>”;
$array1 = array(“a” => “PHP”, “b” => “ASP”, “c” => “JSP”, “VB”);
$array2 = array(“a” => “PHP”, “b” => “AS”, “HTML”);
$array3 = array_intersect_key($array1, $array2);
print_r($array3);
?>

Output

Array
(
[a] => PHP
[b] => ASP
[0] => VB
)

Share