Definition and usage
The array_diff_key() function returns an array containing all keys that are in the compared array but are not in any other parameter array.
Grammar
array_diff_key(array1,array2,array3...)
Parameters
Description
array1 required. The first array to compare with other arrays.
array2 required. The array to compare to the first array.
array3 is optional. The array to compare to the first array. There can be multiple.
Tips and Notes
Tip: You can compare one or more arrays with the first array.
Note: Only key names are used for comparison.
Example
"Cat",1=>"Dog",2=>"Horse"); $a2=array(2=>"Bird", 3=>"Rat",4=>"Fish"); $a3=array(5=>"Horse",6=>"Dog",7=>"Bird"); print_r(array_diff_key ($a1,$a2,$a3)); ?>
Output:
Array ( [0] => Cat [1] => Dog )