[DOC-CVS] [doc-en] master: Add note about SORT_REGULAR + numeric strings bug to array_unique() (#4958)
[email protected] (Sebastian Hädrich via GitHub)
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> Co-authored-by: Louis-Arnaud <[email protected]> * Change <para> to <simpara> and unwrap not from param description Co-authored-by: Louis-Arnaud <[email protected]> See https://github.com/php/doc-en/pull/4958#discussion_r3630654852 Co-authored-by: Louis-Arnaud <[email protected]> --------- Co-authored-by: Louis-Arnaud <[email protected]> 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>