What is the best method in PHP to count the occurrences of values in an array?

To count the occurrences of values in an array in PHP, you can use the `array_count_values()` function. This function returns an associative array where the keys are the unique values in the original array, and the values are the number of times each value appears. This allows you to easily determine the frequency of each value in the array.

$array = [1, 2, 2, 3, 3, 3];
$valueCounts = array_count_values($array);

foreach ($valueCounts as $value => $count) {
    echo "Value: $value, Count: $count" . PHP_EOL;
}