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);...