Skip to content

array_unique with SORT_REGULAR flag does not always work as expected #1463

@davidjr82

Description

@davidjr82

Description

The following code:

<?php
print_r(array_unique(["100","100","25","15p100","25","25"], SORT_REGULAR));

Resulted in this output:

Array
(
    [0] => 100
    [2] => 25
    [3] => 15p100
    [4] => 25
)

But I expected this output instead:

Array
(
    [0] => 100
    [2] => 25
    [3] => 15p100
)

It happens because of the value "15p100", if I remove the letter "p" it works. It happens with any character not digit (example "15+100").

PHP Version

PHP 8.1.2

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions