Menu Samaritan's Purse

ARRAY_UNIQUE

Removes duplicate values from an array

SYNTAX

array_unique ( array $array [, int $sort_flags = SORT_STRING ] ) : array

PARAMETERS

array

The input array.

sort_flags

The optional second parameter sort_flags may be used to modify the sorting behavior using these values:

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

RETURN

Returns the filtered array.

EXAMPLES

ARRAY

Array
(
    [a] => green
    [0] => red
    [1] => blue
    [3] => 4
    [5] => 3
)

FLAGS | SORT_REGULAR

Array
(
    [a] => green
    [0] => red
    [1] => blue
    [3] => 4
    [4] => 4
    [5] => 3
    [6] => 3
)

FLAGS | SORT_NUMERIC

Array
(
    [a] => green
    [3] => 4
    [5] => 3
)

FLAGS | SORT_STRING

Array
(
    [a] => green
    [0] => red
    [1] => blue
    [3] => 4
    [5] => 3
)

FLAGS | SORT_LOCALE_STRING

Array
(
    [a] => green
    [0] => red
    [1] => blue
    [3] => 4
    [5] => 3
)

PHP