<?php
$arr1 = [
'name1' => 'Имя',
'name2' => 'Имя2'
];
$arr2 = [
'name1' => 'Имя2',
'name2' => 'Имя4',
'link' => 'href'
];
function array_cross(&$arr1,&$arr2,$r=false) {
foreach($arr1 as $k1=>$a1) {
$f=false;
foreach($arr2 as $k2=>$a2)
if($a1==$a2) {$f=true;break;}
if(!$f) unset($arr1[$k1]);
}
if(!$r) array_cross($arr2,$arr1,true);
}
array_cross($arr1,$arr2);
echo '$arr1[] = ';
print_r($arr1);
echo '<br>$arr2[] = ';
print_r($arr2);
/*
$arr1[] = Array ( [name2] => Имя2 )
$arr2[] = Array ( [name1] => Имя2 )
*/
?>