PHP 5 >= 5.1.0, PHP 7, PHP 8
array_diff_key - Computes the difference of arrays using keys for comparison

array_diff_key( array$array, ... array$arrays ): array

Compares the keys from array against the keys from arrays and returns the difference. This function is like array_diff except the comparison is done on the keys instead of the values.



The array to compare from


Arrays to compare against

Return Values

Returns an array containing all the entries from array whose keys are absent from all of the other arrays.



This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff_key($array1[0], $array2[0]);.

Related Functions

Example of array_diff_key

Show all examples for array_diff_key

PHP Version:

Function array_diff_key:

Arrays Functions

Most used PHP functions