Home > PHP > Function > Arrays > array_unique()

array_unique()

array_unique - Removes duplicate values from an array

Syntax

array array_unique (array $array, int $sort_flags)

Arguments

  • array - The input array.
  • sort_flags - The optional second parameter sort_flags may be used to modify the sorting behavior using these values: Sorting type flags: SORT_REGULAR - compare items normally (don\'t change types) SORT_NUMERIC - compare items numerically SORT_STRING - compare items as strings SORT_LOCALE_STRING - compare items as strings, based on the current locale. Added in PHP 4.4.0 and 5.0.2.

Description

Takes an input array and returns a new array without duplicate values.

Version

PHP 4.0.1, 5

Return value

Returns the filtered array.