PHP array_count_values () function
Examples
Statistical values in an array number of occurrences:
<?php
$a=array("A","Cat","Dog","A","Dog");
print_r(array_count_values($a));
?>
$a=array("A","Cat","Dog","A","Dog");
print_r(array_count_values($a));
?>
Running instance »
Definition and Usage
array_count_values () function is used to count the number of values in an array appearing.
grammar
array_count_values( array )
参数 | 描述 |
---|---|
array | 必需。规定需要统计数组中所有值出现次数的数组。 |
technical details
return value: | Returns an associative array, key elements of which is the value of the original array, the key is the number of occurrences of the value in the original array. |
---|---|
PHP version: | 4+ |
Complete PHP Array Reference