How can the use of native PHP functions like array_count_values simplify the process of counting occurrences in an array?

When counting occurrences in an array, using native PHP functions like array_count_values can simplify the process by automatically counting the occurrences of each unique value in the array and returning an associative array where the keys are the unique values and the values are the counts of each value.

// Sample array
$array = array("apple", "banana", "apple", "orange", "banana", "apple");

// Count the occurrences of each value in the array
$occurrences = array_count_values($array);

// Output the counts
print_r($occurrences);