PHP统计一个数组中相同元素的个数
例如:
<?php
$a=array("Cat","Dog","Horse","Dog");
print_r(array_count_values($a));
?>
输出:
Array ( [Cat] => 1 [Dog] => 2 [Horse] => 1 )
例如:
<?php
$a=array("Cat","Dog","Horse","Dog");
print_r(array_count_values($a));
?>
输出:
Array ( [Cat] => 1 [Dog] => 2 [Horse] => 1 )
Hi