What is the purpose of using array_count_values() in PHP?

The purpose of using array_count_values() in PHP is to count the frequency of values in an array. This function will return an associative array where the keys are the unique values from the original array, and the values are the count of how many times each value appears.

$array = array("apple", "banana", "apple", "orange", "banana", "apple");
$value_counts = array_count_values($array);

print_r($value_counts);