Easy Tutorial
❮ Func Date Mktime Func Curl_Version ❯

PHP array_unique() Function

Complete PHP Array Reference Manual

Example

Remove duplicate values from an array:


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, the first value is retained, and the other values are removed.

Note: The retained array will maintain the key type of the first array element.


Syntax

Parameter Description
array Required. Specifies the array.
sortingtype Optional. Specifies the sort type. Possible values: SORT_STRING - Default. Treats each item as a string. <br> SORT_REGULAR - Sorts items in a regular order (Standard ASCII, no type change). <br> SORT_NUMERIC - Treats each item as a number. <br> SORT_LOCALE_STRING - Treats each item as a string, based on the current locale (can be changed with setlocale()).

Technical Details

Return Value: Returns the filtered array.
PHP Version: 4.0.1+
--- ---
Update Log: In PHP 5.2.10, the default value of sortingtype was changed back to SORT_STRING. <br> <br> In PHP 5.2.9, the default value of sortingtype was changed to SORT_REGULAR. Prior to this, the default value was SORT_STRING.
--- ---
❮ Func Date Mktime Func Curl_Version ❯