Req #79890 [NEW]: array_unique does not allow strict comparison

From: Date: Thu, 23 Jul 2020 15:26:51 +0000
Subject: Req #79890 [NEW]: array_unique does not allow strict comparison
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228201@lists.php.net to get a copy of this message
From:             michael dot vorisek at email dot cz
Operating system: any
PHP version:      7.4.8
Package:          Scripting Engine problem
Bug Type:         Feature/Change Request
Bug description:array_unique does not allow strict comparison

Description:
------------
this should be definitely supported, probably with SORT_UNIQUE_STRICT
constant.

currently, there is not simple way to remove same instance duplicates

Test script:
---------------
$d = new \DateTime('2000-1-1');
print_r(
    array_unique([$d, $d, new \DateTime('2000-1-1')], SORT_REGULAR)
);

Expected result:
----------------
array with 2 DateTime elements

Actual result:
--------------
remove same instance duplicates - not supported by array_unique

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79890&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79890&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79890&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79890&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79890&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79890&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79890&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79890&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79890&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79890&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79890&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79890&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79890&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79890&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79890&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79890&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79890&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79890&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#228201) next »