Skip to content

array_unique: add way to compare items with an identity check (===) #10526

Closed as not planned
@wernerm

Description

@wernerm

Description

The following code:

<?php
var_dump(array_unique([1, "1"], SORT_REGULAR));

Resulted in this output:

array(1) {
  [0]=>
  int(1)
}

But I expected this output instead:

array(2) {
  [0]=>
  int(1)
  [1]=>
  string(1) "1"
}

Adding the SORT_REGULAR flag should result in items being compared normally (not changing item types).

PHP Version

PHP 8.0.20

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions