ID:               37573
 Updated by:       [EMAIL PROTECTED]
 Reported By:      lig at maolek dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Windows XP SP2
 PHP Version:      5.1.4
 New Comment:

>A key that is present in both $array1 and $array2 is showing up in the
output.

Of course it does.
You're comparing array1 to array3 and array2 to array3.


Previous Comments:
------------------------------------------------------------------------

[2006-05-24 05:06:11] lig at maolek dot com

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
        )

)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37573&edit=1

Reply via email to