How to learn PHP Array_intersect_key ()
Definition and usage
The Array_intersect_key () function computes the intersection of an array using the key name comparison.
Array_intersect_key () returns an array that contains all the values of the key names that appear in the array being compared and that appear in all other parameter arrays.
Note: Only key names are used for comparisons.
Grammar
Array_intersect_key (Array1,array2,array3 ...)
Parameters
Describe
Array1 required. The first array to compare with the other array.
Array2 required. The array to compare with the first array.
Array3 is optional. The array to compare with the first array. Can have more than one.
Example 1
"Cat",1=> "Dog",2=> "Horse"); $a 2=array (2=> "Bird",0=> "Cat",4=> "Fish"); Print_r (Array_intersect_key ($a 1, $a 2));?>
Output:
Array ([0] = Cat [2] = Horse)
Example 2
"Cat",1=> "Dog",2=> "Horse"); $a 2=array (2=> "Bird",3=> "Rat",4=> "Fish"); $a 3=array (2=> "Dog",6=> "Cow",7=> "Bird"); Print_r (Array_intersect_key ($a 1, $a 2, $a 3));?>
Output:
Array ([2] = Horse)
http://www.bkjia.com/PHPjc/834961.html www.bkjia.com true http://www.bkjia.com/PHPjc/834961.html techarticle How to learn php array_intersect_key () Definition and usage the Array_intersect_key () function uses the key name comparison to calculate the intersection of an array. Array_intersect_key () returns an array that contains the ...