Hello Bruno, the documentation says array_diff() uses explicit string casting. Maybe it is time to fix this to object comparision. But then what about mixed arrays? In my opinion it was broken before and you just got lucky with using a debug feature without even knowing. Now the current PHP version at least offers you to do it correctly. Speaking of the mentioned PEAR issue. Now what is your string representation there? Was it actually correct? Was it intended that you were simply comparing class name and handle? Or were you actually expecting to compare the data? Honestly i would expect to compare by elements, say you fetch from a person database into two arrays that are modified differently using php code. Now i'd like to do the test based on the elements, say the ones from the persons.name column. And it does not matter what the different object IDs are....becasue two fetch operations would result in two different IDs even if theay are referring to the same data row. So in this case you apperently do not want to use array_diff() at all. You want to use array_udiff_*(). In the end object to string conversion other than something that leads to a text that can be used on a html or txt file pretty much sounds like a design flaw.
marcus Monday, July 30, 2007, 9:30:12 PM, you wrote: > On 7/30/07, Marcus Boerger <[EMAIL PROTECTED]> wrote: >> Hello Pavel, >> >> I still fail to understand why spl_object_hash() does not work for you. > Hello. > Just as a side note, this broke a few things for me. For example, in > an application, I have 2 arrays of objects, and I try to call > array_diff() on them. > Before PHP 5.2, it would work, possibly because array_diff() would > cast the objects as strings, and then compare them (if I understood > the problem correctly). > Now, this doesn't work anymore, because the object can't be cast to > string by default. > Of course, I could add a __toString() method to the objects and return > something there, but problem is, all objects are extended from a base > class from PEAR (it's DB_DataObject), and it wouldn't be a Good Thing > to modify the PEAR class directly (updates would break). > So, I got kind of stuck, and tried to add the __toString() dynamically > to the objects in question using the "runkit" PECL package, but > although it adds the method correctly, PHP doesn't recognize it as a > magic method, and won't call it when needed (filed bug #11691 on PECL > for it). > Do you think there's an easy and clean approaching to solve this kind > of problem? Or maybe the problem should be solved on array_diff() and > other functions to make them not try to cast the object as a string to > compare? > Thanks > -- > Bruno Lustosa <[EMAIL PROTECTED]> > ZCE - Zend Certified Engineer - PHP! > http://www.lustosa.net/ Best regards, Marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php