首页 > php数组 > php统计数组元素重复个数函数

php统计数组元素重复个数函数

统计数组只要利用count但要统计重复数组我们需要遍历一下数组这样就可以统计出来了,下面一起来看看例子,希望对各位会有所帮助.

PHP实例代码如下:

<?php   
$arr=array   
(   
  "01",   
  "02",   
  "01",   
  "02",   
  "03"   
);   
$rs=array();   
foreach($arr as $v){   
  if (isset($rs[$v])) { 
 $rs[$v]++;     
  } else { 
 $rs[$v] = 1; 
  } 
}   
print_r($rs); 
?>


文章链接:http://www.phprm.com/shuzu/fs3237.html

随便收藏,请保留本文地址!

标签:函数 数组 重复个数

相关文章

发表留言