PHP array_count_values()Functions
Complete PHP Array Reference Manual
Examples
Count the number of occurrences of all values in an array:
<?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));
?>
Run Example »
Definition and Usage
The array_count_values() function is used to count the number of occurrences of all values in an array.
Syntax
array_count_values(array)
| Parameters | Description |
|---|---|
| array | Required. Specifies the array for which to count the number of occurrences of all values. |
Technical Details
| Return value: | Returns an associative array whose element keys are the values of the original array, and the key values are the number of times those values occur in the original array. |
|---|---|
| PHP Version: | 4+ |
Complete PHP Array Reference Manual Other Extensions