#37573 [Opn->Bgs]: Wrong output for function array_diff_ukey
| From: | tony2001@php.net | Date: | Wed, 24 May 2006 06:50:47 +0000 |
| Subject: | #37573 [Opn->Bgs]: Wrong output for function array_diff_ukey | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-97491@lists.php.net to get a copy of this message | ||
ID: 37573
Updated by: tony2001@php.net
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