|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-06-21 17:00 UTC] tony2001@php.net
[2005-06-21 17:07 UTC] fjortiz at comunet dot es
[2005-06-21 17:09 UTC] fjortiz at comunet dot es
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 19:00:01 2025 UTC |
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.