Home > Article > Backend Development > Determine whether the same value exists in the array under PHParray_unique_PHP tutorial
array_unique(PHP 4 >= 4.0.1, PHP 5)
array_unique -- Remove duplicate values from the array
Description
array array_unique (array array)
array_unique() accepts array as input and returns a new array without duplicate values.
Note that the key name remains unchanged. array_unique() first sorts the values as strings, then retains only the first encountered key for each value, and then ignores all subsequent keys. This does not mean that the first occurrence of the same value in an unsorted array will be preserved.
Note: Two units are considered the same if and only if (string) $elem1 === (string) $elem2. That is, when the expressions of the strings are the same.
The first unit will be retained.
Example 1. array_unique() example
array_unique(PHP4=4.0.1,PHP5) array_unique--Remove duplicate values in the array Description arrayarray_unique(arrayarray ) array_unique() accepts an array as input and returns a new array without duplicate values. ...