Php array_unique is actually very useful. I often see repeated content in regular expressions, but I like to delete repeated array values with array_unique.
Php array_unique is actually very useful. I often see repeated content in regular expressions, but I like to delete repeated array values with array_unique.
Array_unique
("= 4.0.1, PHP 5" in PHP 4)
Array_unique-delete an array of repeated values
Description
Array array_unique (array $ array [Abstract $ sort_flags = SORT_REGULAR])
Take an input array and return a new array with no repeated values.
Note that the key is saved. Various values of array_unique () are treated as strings, and then each value of the first key that is continuously encountered ignores all the keys below. This does not mean that the key first batch of unordered values will be maintained.
Note: two factors are considered equal when and only when (string) $ elem1 ===( string) $ elem2. VERBAL: When the strings are the same. The first item will be used.
Parameters
Array
Input array.
Sort_flags
The optional second parameter sort_flags can be used to modify the sorting behavior and use these values:
Sorting type ID:
SORT_REGULAR-general comparison (without changing the type)
SORT_NUMERIC-numerical comparison
SORT_STRING-string comparison
SORT_LOCALE_STRING-compares strings based on the current region. The time is in PHP 4.4.0 and 5.0.2. In PHP 6, the locale of the system it uses can be changed to setlocale (). From PHP 6, you must use the i18n_loc_set_default () function.
Return Value
Returns the filter array.
Modify
Version description
Optional sort_flags at 5.2.9.
Instance
Example #1 array_unique ()