Bug #81692 [Opn->Ver]: array_unique bug
Edit report at https://bugs.php.net/bug.php?id=81692&edit=1
ID: 81692
Updated by: cmb@php.net
Reported by: stanislav dot eismont at gmail dot com
Summary: array_unique bug
-Status: Open
+Status: Verified
Type: Bug
Package: Arrays related
Operating System: ubuntu 20.04
PHP Version: 7.4.26
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Indeed, broken as of PHP 7.0.0: <https://3v4l.org/PXQZe>.
Previous Comments:
------------------------------------------------------------------------
[2021-12-03 11:30:02] stanislav dot eismont at gmail dot com
Description:
------------
array_unique returns incorrect result with SORT_REGULAR flag.
Test script:
---------------
<?php
$array = ["red", "color" => "red", 78, 78, 12, "12",
false, null, false, 0, true, 1, 0, null, 2.12, "2.12", 8, "-s"];
var_dump(array_unique($array, SORT_REGULAR));
Expected result:
----------------
Expected one "red" value printed:
array(11) {
[0]=>
string(3) "red"
// ...
}
Actual result:
--------------
Actually "red" printed twice:
array(11) {
[0]=>
string(3) "red"
["color"]=>
string(3) "red"
// ...
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81692&edit=1
Thread (3 messages)