array_intersect_ukey

It finds the intersection of arrays using a callback function on the keys for comparison

Example

<?php
function compare_keys($key1, $key2)
{
if ($key1 == $key2)
return 0;
else if ($key1 > $key2)
return 1;
else
return -1;
}

echo “<pre>”;
$array1 = array(‘key1’  => PHP, ‘key2’  => 11, ‘key3’  => 22, ‘key4’ => 22);
$array2 = array(‘key5’ => 5, ‘key1’ => 55, ‘key7’ => 44, ‘key8’   => 55);
print_r(array_intersect_ukey($array1, $array2, ‘compare_keys’));
?>

Output

Array
(
[key1] => PHP
)