Home  >  Article  >  php教程  >  php高效去除数组重复值

php高效去除数组重复值

WBOY
WBOYOriginal
2016-06-13 10:03:441086browse

本文章是一个简单的高效的去除一维数组重复值的代码,有需要的朋友简单的参考一下哦。

 代码如下 复制代码

$a=array("a"=>"Cat","b"=>"Dog","c"=>"Cat");
print_r(array_unique($a));
?>

Array ( [a] => Cat [b] => Dog )

结果我们把Cat 只保留了一个哦。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn