The array_intersect_key() function used for compares the keys of two or more arrays, and returns common elements.
Syntax
array_intersect_key(array1,array2,array3...);
Example
$array1 = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$array2 = array("a"=>"red","b"=>"green","c"=>"blue");
print_r(array_intersect_key($array1,$array2));
Output
Array ( [a] => red [b] => green [c] => blue )
Copyright ©2022 coderraj.com. All Rights Reserved.