From: for-bugs at hnw dot jp
Operating system: any
PHP version: 5.2.9RC1
PHP Bug Type: Arrays related
Bug description: array_unique has backward compatibility problem, and
SORT_REGULAR is confusing
Description:
------------
In PHP5.2.9RC1, array_unique() returns different result because of element
ordering in array. Reproduce code shows this difference.
It is because SORT_REGULAR never cast array elements and compares them
with ==. I think it's better for SORT_REGULAR to compare elements by using
=== instead of ==.
PHP 5.2.9RC1's array_unique() also has backward compatibility ploblem.
Considering backward compatibility, default sort_flag should be
SORT_STRING.
Reproduce code:
---------------
<?php
var_dump(arary_unique(array(0,"","0"))));
var_dump(arary_unique(array("","0",0))));
Expected result:
----------------
I don't know, but 2 results should be same.
Actual result:
--------------
array(1) {
[0]=>
int(0)
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(1) "0"
}
--
Edit bug report at http://bugs.php.net/?id=47370&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47370&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47370&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47370&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47370&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47370&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47370&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47370&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47370&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47370&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47370&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47370&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47370&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47370&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47370&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47370&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47370&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47370&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47370&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47370&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47370&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47370&r=mysqlcfg