php 数组去重[
示例#1 array_unique()示例
<?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"
}