申明(引荐进修:PHP编程从入门到通晓)
array array_count_values ( array $input )array_count_values()
返回一个数组,该数组用 input 数组中的值作为键名,该值在 input 数组中涌现的次数作为值。
array_count_values() 例子
<?php $array = array(1, "hello", 1, "world", "hello"); print_r(array_count_values ($array)); ?>
以上例程会输出:
Array ( [1] => 2 [hello] => 2 [world] => 1 )
以上就是php怎样统计数组中反复的值的细致内容,更多请关注ki4网别的相干文章!