unique.php
Table of Contents
Functions
- unique() : array<string|int, mixed>
- Removes duplicate values from an array and reindexes it.
Functions
unique()
Removes duplicate values from an array and reindexes it.
unique(array<string|int, mixed> $array[, int $flags = SORT_STRING ]) : array<string|int, mixed>
Combines the functionality of array_unique() and array_values(): first removes duplicates, then reindexes the array numerically starting at 0.
The optional $flags
parameter modifies the comparison behavior, possible values:
- SORT_REGULAR: Compare items normally (don't change types).
- SORT_NUMERIC: Compare items numerically.
- SORT_STRING: Compare items as strings.
- SORT_LOCALE_STRING: Compare items as strings, based on the current locale.
Parameters
- $array : array<string|int, mixed>
-
The input array.
- $flags : int = SORT_STRING
-
[optional] Comparison behavior flag. Default is SORT_STRING.
Tags
Return values
array<string|int, mixed> —The filtered array with unique values, reindexed from 0.