好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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

查看更多关于php统计数组元素重复个数函数 - php数组的详细内容...

  阅读:46次