The array_count_values() function counts the values of an array.
PHP array_count_values() function has the following syntax.
array_count_values(array)
It returns an associative array, where the keys are the original array's values, and the values are the number of occurrences.
Count all the values of an array
<?php
$a=array("A","Cat","Dog","A","Dog");
print_r(array_count_values($a));
?>
The code above generates the following result.
Count an associative array
<?php
$age=array("PHP"=>"5","Python"=>"7","Java"=>"3");
print_r(array_count_values($age));
?>
The code above generates the following result.