Let's take a look at PHP today.Array_intersect_key ()For the function instance tutorial, let's take a look at its simple description, and then look at the tutorial.
Array_intersect_key ()Definition and usage
The array_intersect_key () function compares two or more arrays, and returns the entry and value of an array from the first array, only in the Key currently on all other arrays.
Syntax
array_intersect_key(array1,array2,array3...)
| Parameter |
Description |
| Array1 |
Required. The first array will work with other |
| Array2 |
Required. An array is relative to the first array. |
| Array3 |
Optional. An array is relative to the first array. |
Tips and instructions
Tip: You can compare the first array with an array, or you like it.
Note: Only the key is the comparison.
Example 1
<?php$a1=array(0=>"Cat",1=>"Dog",2=>"Horse");$a2=array(2=>"Bird",0=>"Cat",4=>"Fish");print_r(array_intersect_key($a1,$a2));?>
The output data is.
Array ( [0] => Cat [2] => Horse )
Now let's take a look at instance 2.
<?php$a1=array(0=>"Cat",1=>"Dog",2=>"Horse");$a2=array(2=>"Bird",3=>"Rat",4=>"Fish");$a3=array(2=>"Dog",6=>"Cow",7=>"Bird");print_r(array_intersect_key($a1,$a2,$a3));?>
Output result.
Array ( [2] => Horse )