Home  >  Article  >  Backend Development  >  PHP efficiently removes duplicate values ​​from array_PHP tutorial

PHP efficiently removes duplicate values ​​from array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:59:33788browse

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.

$a=array("a"=>"Cat","b"=>"Dog","c"=>"Cat");
print_r(array_unique($a));
?>
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

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

As a result, we only kept one Cat. http://www.bkjia.com/PHPjc/631314.htmlwww.bkjia.com
true
http: //www.bkjia.com/PHPjc/631314.html
TechArticleThis 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