From:             tchunai at ig dot com dot br
Operating system: Windows
PHP version:      5.2.4
PHP Bug Type:     Arrays related
Bug description:  Wrong results in array_diff_uassoc (php 5.2.3)

Description:
------------
array_diff_uassoc:

    If in both array's of comparison will have some key 0 (zero), the same
it is discarded and enclosed as different in the return of
'array_diff_uassoc'.

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", 0 =
"red");
    $array2 = array("a" = "green", "b" = "Brown", "c" = "blue", 0 =
"red");
    
    $result = array_diff_uassoc($array1, $array2, "key_compare_func");
    print_r($result);

Expected result:
----------------
    Array
    (
    )

Actual result:
--------------
    Array
    (
        [b] = brown
        [c] = blue
        [0] = red
    )

-- 
Edit bug report at http://bugs.php.net/?id=42838&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42838&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42838&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42838&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42838&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42838&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42838&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42838&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42838&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42838&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42838&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42838&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42838&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42838&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42838&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42838&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42838&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42838&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42838&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42838&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42838&r=mysqlcfg

Reply via email to