This article is a simple and efficient code for removing duplicate values from a one-dimensional array. Friends in need can simply refer to it.
The code is as follows
代码如下 |
复制代码 |
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Cat");
print_r(array_unique($a));
?>
Array ( [a] => Cat [b] => Dog )
|
|
Copy code
|
|
$a=array("a"=>"Cat","b"=>"Dog","c"=>"Cat");
print_r(array_unique($a));
?>
Array ( [a] => Cat [b] => Dog )
As a result, we only kept one Cat.
http://www.bkjia.com/PHPjc/631314.htmlwww.bkjia.com
trueTechArticleThis article is a simple and efficient code for removing duplicate values from a one-dimensional array. Friends in need can provide a simple reference. Just a moment. The code is as follows Copy the code ?php $a=array(a=Cat,b=Dog,c=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