Func Array Unique
# PHP array_unique() Function
[Complete PHP Array Reference](#)
## Example
Remove duplicate values from an array:
"red","b"=>"green","c"=>"red");
print_r(array_unique($a));
?>
[Run Example Β»](#)
* * *
## Definition and Usage
The array_unique() function is used to remove duplicate values from an array. If two or more array values are the same, only the first value is kept, and the other values are removed.
**Note:** The retained array will keep the key type of the **first** array item.
* * *
## Syntax
array_unique(_array_)
| Parameter | Description |
| :--- | :--- |
| _array_ | Required. Specifies the array. |
| _sortingtype_ | Optional. Specifies the sorting type. Possible values: * SORT_STRING - Default. Treats each item as a string. * SORT_REGULAR - Sorts items in regular order (Standard ASCII, does not change type). * SORT_NUMERIC - Treats each item as a number. * SORT_LOCALE_STRING - Treats each item as a string, based on the current locale (can be changed via [setlocale()](#)). |
## Technical Details
| Return Value: | Returns the filtered array. |
| :--- |
| PHP Version: | 4.0.1+ |
| Changelog: | In PHP 5.2.10, the default value for _sortingtype_ was changed back to SORT_STRING. In PHP 5.2.9, the default value for _sortingtype_ was changed to SORT_REGULAR. In versions prior to this, the default value for _sortingtype_ was SORT_STRING. |
* * Complete PHP Array Reference](#)
YouTip