Home  >  Article  >  Backend Development  >  Count duplicate values

Count duplicate values

WBOY
WBOYOriginal
2016-07-25 09:08:22964browse
Count duplicate values
  1. $array=array(1,2,3,4,5,6,8,5,2,3,6,3,5,2,3,6,5,2, 2);
  2. print_r($array);
  3. echo '
    ';
  4. $b=array_count_values($array);//Count duplicate values
  5. foreach($b as $key=>$value){
  6. if($value>1){
  7. echo 'Duplicate value'.''.$key.''.'---------'.'Duplicate Times'.$value.'
    ';
  8. }
  9. }
Copy code


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
Previous article:PHP takes remainderNext article:PHP takes remainder