array array_intersect_key ( array $array1, array $array2 [, array $array3 ...] );
It returns an array containing all the values of array1 which have matching keys that are present in all the arguments.
Sr.No | Parameter & Description |
---|---|
1 |
array1(Required) The first array is the array that the others will be compared with. |
2 |
array2(Required) This is an array to be compared with the first array |
3 |
array3(Optional) This is an array to be compared with the first array |
It returns FALSE if there is any error.
Try out following example −
<?php $input1 = array('black' => 1, 'red' => 2, 'green' => 3 ); $input2 = array('green' => 4, 'black' => 5, 'pink' => 6,); $result = array_intersect_key($input1, $input2); print_r($result); ?>
This will produce the following result −
Array ( [black] => 1 [green] => 3 )