<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
复制代码
输出结果:
Array
(
[a] => green
[0] => red
[1] => blue
)
例2. array_unique() 和类型
<?php
$input = array(4, "4", "3", 4, 3, "3");
$result = array_unique($input);
var_dump($result);
?>
复制代码
输出结果:
array(2) {
[0] => int(4)
[2] => string(1) "3"
}
登录后复制





09-19 08:32