This function is available since PHP 4.0.0.
The array_count_values() function is used to count the occurrences of all values in an array and return an associative array. The key of the returned array is the value in the original array, and the value is the number of times the value appears in the original array.
<span class="fun">array_count_values(array $array): array</span>
Returns an associative array where the key of the array is the value of the input array, and the value is the number of times the value appears in the input array.
 <?php
$array = array(1, "apple", 2, 3, "apple", 1, 3, "banana", "apple");
$result = array_count_values($array);
print_r($result);
?>In this example, the array contains multiple duplicate values, such as the number 1 and the string "apple". After calling the array_count_values() function, the returned result will be an associative array, indicating the number of times each element appears in the original array. The output result is:
 Array ( [1] => 2 [apple] => 3 [2] => 1 [3] => 2 [banana] => 1 )