The array_unique()
function removes duplicate values from an array.
If multiple values are found equal, the first value and its key will be kept and others will be removed.
The basic syntax of the array_unique()
function is given with:
array_unique(array, sort_flags);
The array_unique()
function accepts the following parameters.
Parameter | Description |
---|---|
array | Required. Specifies the array to work on. |
sort_flags |
Optional. Specifies how array items s hould be compared. Possible values are:
|
Example : following example to show remove duplicate values from an array
Output :
Array
(
[a] => web
[b] => designing
[c] => house
)