[doc-en] master: Add note about SORT_REGULAR + numeric strings bug to array_unique() (#4958)
| From: | Sebastian Hädrich via GitHub | Date: | Tue, 25 Aug 2026 20:24:21 +0000 |
| Subject: | [doc-en] master: Add note about SORT_REGULAR + numeric strings bug to array_unique() (#4958) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23637@lists.php.net to get a copy of this message | ||
Author: Sebastian Hädrich (shaedrich)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-08-25T22:24:18+02:00
Commit: https://github.com/php/doc-en/commit/47cbf365f535be1517473eee446e94d096778ca8
Raw diff: https://github.com/php/doc-en/commit/47cbf365f535be1517473eee446e94d096778ca8.diff
Add note about SORT_REGULAR + numeric strings bug to array_unique() (#4958)
* Add note about SORT_REGULAR + numeric strings bug to array_unique()
As suggested in https://github.com/php/php-src/issues/20262#issuecomment-3445270671
* Fix indention
* Use <para> instead of <simpara>
* Make text more precise
* Wording improvements
Co-authored-by: lacatoire <la.catoire@gmail.com>
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
* Change <para> to <simpara> and unwrap not from param description
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
See https://github.com/php/doc-en/pull/4958#discussion_r3630654852
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
---------
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Changed paths:
M reference/array/functions/array-unique.xml
Diff:
diff --git a/reference/array/functions/array-unique.xml b/reference/array/functions/array-unique.xml
index 2ec4980816ab..3bd1d0a6d2d2 100644
--- a/reference/array/functions/array-unique.xml
+++ b/reference/array/functions/array-unique.xml
@@ -54,8 +54,17 @@
Comparison type flags:
<itemizedlist>
<listitem>
- <simpara><constant>SORT_REGULAR</constant> - compare items normally
+ <simpara><constant>SORT_REGULAR</constant> - compare items normally
(don't change types)</simpara>
+ <note>
+ <simpara>
+ When combining <constant>SORT_REGULAR</constant> with arrays
+ mixing numeric and non-numeric strings, the sort-then-compare
+ algorithm may not place equal elements adjacent, which can
+ leave duplicates in the result. Use
+ <constant>SORT_STRING</constant> to avoid this.
+ </simpara>
+ </note>
</listitem>
<listitem>
<simpara><constant>SORT_NUMERIC</constant> - compare items
numerically</simpara>