The array_unique Function
The array_unique
function performs
removal of duplicate elements (duplicates)
from an array.
Syntax
array_unique(array $array, int $flags = SORT_STRING): array
Example
Let's remove duplicates from the array:
<?php
$arr = [1, 1, 1, 2, 2, 3];
var_dump(array_unique($arr));
?>
Code execution result:
[1, 2, 3]
See Also
-
the
array_count_values
function,
which counts the occurrences of all values in an array