Array_unique (PHP 4 >= 4.0.1, PHP 5)
Array_unique--Removes duplicate values from the divisor group
Description
Array array_unique (array array)
Array_unique () accepts the array as input and returns a new array with no duplicate values.
Note The key name remains unchanged. Array_unique () Sorts the values first as a string, then retains only the first key name encountered for each value, and then ignores all subsequent key names. This does not mean that the key name of the first occurrence of the same value in an unordered array is preserved.
Note: When and only if (string) $elem 1 = = = (string) $elem 2 o'clock two units are considered identical. That is, when the expression of a string is the same.
The first unit will be retained.
Example 1. Array_unique () example
Copy the Code code as follows:
$input = Array ("A" = "green", "Red", "b" = "green", "Blue", "Red");
$result = Array_unique ($input);
Print_r ($result);
?>
The example above will output:
Copy the Code code as follows:
Array
(
[A] = Green
[0] = Red
[1] = Blue
)
Example 2. Array_unique () and type
The example above will output:
Copy the Code code as follows:
$input = Array (4, "4", "3", 4, 3, "3");
$result = Array_unique ($input);
Var_dump ($result);
?>
Copy the Code code as follows:
Array (2) {
[0] = Int (4)
[2] = = string (1) "3"
}
The above describes the UniqueID PHP in the array to determine if there is the same value array_unique, including the UniqueID aspects of the content, I hope that the PHP tutorial interested in a friend to help.