Query: array_diff_key
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ARRAY_DIFF_KEY(3) 1 ARRAY_DIFF_KEY(3) array_diff_key - Computes the difference of arrays using keys for comparisonSYNOPSISarray array_diff_key (array $array1, array $array2, [array $...])DESCRIPTIONCompares the keys from $array1 against the keys from $array2 and returns the difference. This function is like array_diff(3) except the comparison is done on the keys instead of the values.PARAMETERSo $array1 - The array to compare from o $array2 - An array to compare against o $... - More arrays to compare againstRETURN VALUESReturns an array containing all the entries from $array1 whose keys are not present in any of the other arrays.EXAMPLESExample #1 array_diff_key(3) example The two keys from the key => value pairs are considered equal only if (string) $key1 === (string) $key2 . In other words a strict type check is executed so the string representation must be the same. <?php $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_diff_key($array1, $array2)); ?> The above example will output: array(2) { ["red"]=> int(2) ["purple"]=> int(4) }NOTESNote 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]);.SEE ALSOarray_diff(3), array_udiff(3), array_diff_assoc(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_diff_ukey(3), array_intersect(3), array_intersect_assoc(3), array_intersect_uassoc(3), array_intersect_key(3), array_intersect_ukey(3). PHP Documentation Group ARRAY_DIFF_KEY(3)
Related Man Pages |
---|
array_replace(3) - php |
array_intersect_assoc(3) - php |
array_merge(3) - php |
array_udiff(3) - php |
array_udiff_assoc(3) - php |
Similar Topics in the Unix Linux Community |
---|
Bash arrays that compare ip addresses. |
How to use string in array name? |
Little explanation needed on array |
Comparison between two arrays |
Compare bash arrays issue |