Date: 12/28/00
- Next message: Capesesp - Divisao de Informatica: "[PHP-DEV] RES: PHP 4.0 Bug #8460 Updated: Installation"
- Previous message: Rasmus Lerdorf: "Re: [PHP-DEV] License Choice: RE: [PHP-DEV] readline extension status?"
- Next in thread: Stig Venaas: "Re: [PHP-DEV] array_diff() failures"
- Reply: Stig Venaas: "Re: [PHP-DEV] array_diff() failures"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Stig,
I've uncovered cases where array_diff() fails to produce the correct
result. I had two identical arrays (unsorted) and I ran array_diff() on
them, expecting to get an empty array back, but array_diff() did produce
some differences. This stems from the fact that you sort the arrays
yourself in the array_diff() and set the comparison function to
SORT_REGULAR. Since the regular comparison function is
non-deterministic, the arrays might be sorted differently depending on
the original order of the elements.
There are two solutions: either users have to presort their arrays and
specify the comparison functions (sort($foo, SORT_STRING) for example),
or there should be a way to set the comparison function that
array_diff() uses.
Thoughts?
-Andrei
"Music expresses that which can not be said
and on which it is impossible to be silent."
-Victor Hugo
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Capesesp - Divisao de Informatica: "[PHP-DEV] RES: PHP 4.0 Bug #8460 Updated: Installation"
- Previous message: Rasmus Lerdorf: "Re: [PHP-DEV] License Choice: RE: [PHP-DEV] readline extension status?"
- Next in thread: Stig Venaas: "Re: [PHP-DEV] array_diff() failures"
- Reply: Stig Venaas: "Re: [PHP-DEV] array_diff() failures"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

