ID: 33422 Updated by: [EMAIL PROTECTED] Reported By: fjortiz at comunet dot es -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Win2K Server PHP Version: 5.0.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is expected behaviour, because objects in PHP5 are compared as descriptors, i.e. even two identical objects of the same class are different. Previous Comments: ------------------------------------------------------------------------ [2005-06-21 16:56:10] fjortiz at comunet dot es 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 this bug report at http://bugs.php.net/?id=33422&edit=1