From:             fjortiz at comunet dot es
Operating system: Win2K Server
PHP version:      5.0.4
PHP Bug Type:     Arrays related
Bug description:  array_diff_assoc behaving different in PHP5 and PHP 4.3

Description:
------------
array_diff_assoc in PHP5 seems to ignore items whose values  are objects.
This should be irrelevant as this function takes only keys as reference
for comparison. See code.


Reproduce code:
---------------
class Foo       {
        var $dato;      
        function Foo($dato)     {
                $this->dato = $dato;    
        }
}

$array1 = array ("a" => new Foo(5), "b" => new Foo(2), "c" => "azul",
"rojo");
$array2 = array ("a" => new Foo(5), "amarillo", "rojo");
$result = array_diff_assoc ($array1, $array2);

print_r($result);

Expected result:
----------------
PHP 4.3.8:

Output:
Array
(
    [b] => foo Object
        (
            [dato] => 2
        )

    [c] => azul
    [0] => rojo
)

Correct.

The same code with PHP 5.0.4:
Output:
Array
(
    [a] => Foo Object
        (
            [dato] => 5
        )

    [b] => Foo Object
        (
            [dato] => 2
        )

    [c] => azul
    [0] => rojo
)

which is not the same, and not correct in PHP5: [a] item should not be
there.



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

Reply via email to