Remove duplicate values from an array:
The array_unique() function removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed.
Note: The returned array will keep the first array item's key type.
Parameter | Description |
---|---|
array | Required. Specifying an array |
sortingtype | Optional. Specifies how to compare the array elements/items. Possible values:
|
Return Value: | Returns the filtered array |
---|---|
PHP Version: | 4.0.1+ |
Changelog: | The default value of sortingtype was changed back to
SORT_STRING in PHP 5.2.10. The default value of sortingtype was changed to SORT_REGULAR in PHP 5.2.9. Prior to this version, the default value was SORT_STRING. |