|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-05-24 06:50 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Jan 01 11:00:01 2026 UTC |
Description: ------------ unexpected output. Accourding to docs array_diff_ukey "returns an array containing all the values of array1 that have keys that are not present in any of the other arguments". A key that is present in both $array1 and $array2 is showing up in the output. It should be noted that the values of the keys are different, but the example provided in the doc page has the same situation and the key isn't in the output. Reproduce code: --------------- function key_compare_func($a, $b) { if ($a === $b) { return 0; } return ($a > $b)? 1:-1; } $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red", ""); $array2 = array("a" => "green", "yellow", "red", TRUE); $array3 = array("red", "a"=>"brown", ""); $result[] = array_diff_ukey($array1, $array3, "key_compare_func"); $result[] = array_diff_ukey($array2, $array3, "key_compare_func"); print_r($result); Expected result: ---------------- Array ( [0] => Array ( [b] => brown [c] => blue ) [1] => Array ( [2] => 1 ) ) Actual result: -------------- Array ( [0] => Array ( [a] => green [b] => brown [c] => blue ) [1] => Array ( [a] => green [2] => 1 ) )