计算值在数组中出现次数的最佳方法是什么?

I wish to calculate how many times each number appears in the array.

The numbers are all between 1 - 10

So for example: {1,2,2,5,5,6,7,8,2) Would return 3 instances for '2'. And 2 instances for '5' and 1 instance for the rest.

What is the best way to do this, other then me creating 10 for loops?

array_count_values()

print_r(
    array_count_values($array)
);