ID:               47370
 User updated by:  for-bugs at hnw dot jp
 Reported By:      for-bugs at hnw dot jp
 Status:           Open
 Bug Type:         Arrays related
 Operating System: any
 PHP Version:      5.2.9RC1
 New Comment:

Sorry, reproduce code was incorrect. Correct code is below:

<?php
var_dump(array_unique(array(0,"","0")));
var_dump(array_unique(array("","0",0)));


Previous Comments:
------------------------------------------------------------------------

[2009-02-12 16:22:38] for-bugs at hnw dot jp

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 this bug report at http://bugs.php.net/?id=47370&edit=1

Reply via email to