php-Arrays function-array_unique-remove duplicate values ​​in the array_PHP tutorial

WBOY
Release: 2016-07-13 17:51:21
Original
824 people have browsed it

array_unique() removes duplicate values ​​in the array

【Function】
This function will return a new array without duplicate values ​​based on the specified array, and the key names remain unchanged
This function first sorts the values ​​as strings, and then only retains the first encountered key name for each value,
           Then ignore all subsequent key names
This does not mean that the first occurrence of a key with the same value in an unsorted array is retained
【Scope of use】
​​​​​ php4>=4.0.1, php5.
【Use】
            mixed array_unique( array array )
           array/required/original array to be processed by the function
【Example】
[php]
$input=array('c'=>"green",'aed','b'=>'green','blue','bed');
var_dump(array_unique($input));
/*
array(4) {
["c"]=>
string(5) "green"
[0]=>
string(3) "aed"
[1]=>
string(4) "blue"
[2]=>
string(3) "bed"
}
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478192.htmlTechArticlearray_unique() removes duplicate values ​​in the array [Function] This function will return no values ​​based on the specified array New array of repeated values, key names remain the same This function first takes the values ​​as strings...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!