PHP - array_unique
Trieda
Metóda - array_unique
(PHP 4 >= 4.0.1, PHP 5, PHP 7)
Removes duplicate elements in an array. In the result array, each value
occurs at most once. Keys are not affected. Elements are internally compared as
strings using the === operator.
Procedurálne
- function array_unique (array $array, int $sort_flags = SORT_STRING) : array
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $array | array | The input array. | |
| $sort_flags | int | SORT_STRING | An optional parameter. We can use the following flags:
|
Mávratovej hodnoty
Vracia: array
An array with unique values.
Príklady
<?php
$array = [1, 2, 2, 2, 3, 1, 5, 2, 6, 9, 5];
$unique = array_unique($array);
print_r($unique);
Súvisiace manuály
- function array_count_values () : array
