Javatpoint Logo
Javatpoint Logo

PHP array_diff_key() function

This is an inbuilt function of PHP. This function was introduced in PHP 5.1. The array_diff_key() function compares the keys of two or more arrays, and returns entries from array1 that are not present in array2 or array3, etc.


Parameter Description Is compulsory
array1 The array to compare from compulsory
array2 An array to compare against compulsory
array3 More arrays to compare against Optional

Return Type

Returns an array containing the entries from array1 that are not present in any of the other arrays.

Example 1


Array ( [3]=> Boi )

Example 2


Array(  [20] => Laxman   [30] => Rahul [40] => Ganguly [50] => Yuvi )

Example 3


Array ( [b] => Bed )

Example 4


Array ( [a1]=> red  [c3]=> blue  [d4]=> black )

Help Others, Please Share

facebook twitter pinterest