Query: array_diff_ukey
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ARRAY_DIFF_UKEY(3) 1 ARRAY_DIFF_UKEY(3) array_diff_ukey - Computes the difference of arrays using a callback function on the keys for comparisonSYNOPSISarray array_diff_ukey (array $array1, array $array2, [array $...], callable $key_compare_func)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. Unlike array_diff_key(3) a user supplied callback function is used for the indices comparison, not internal function.PARAMETERSo $array1 - The array to compare from o $array2 - An array to compare against o $... - More arrays to compare against o $key_compare_func - The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. int callback (mixed $a, mixed $b)RETURN VALUESReturns an array containing all the entries from $array1 that are not present in any of the other arrays.EXAMPLESExample #1 array_diff_ukey(3) example <?php function key_compare_func($key1, $key2) { if ($key1 == $key2) return 0; else if ($key1 > $key2) return 1; else return -1; } $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_diff_ukey($array1, $array2, 'key_compare_func')); ?> 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_ukey($array1[0], $array2[0], 'callback_func');.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_key(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_UKEY(3)
Related Man Pages |
---|
array_diff_key(3) - php |
array_replace_recursive(3) - php |
array_intersect_assoc(3) - php |
array_diff_uassoc(3) - php |
array_udiff_uassoc(3) - php |
Similar Topics in the Unix Linux Community |
---|
How to find difference between two arrays in Perl? |
Invert Matrix of Data - Perl |
check the difference between 2 array |
sed print flag |
Compare bash arrays issue |