PHP array_count_values() Function

PHP array_count_values Function


PHP array_count_values() function counts the occurrences of all values in an array and returns an associative array formed by the unique value of input array as keys, and the number of their occurrences in the array as values.

Syntax

array_count_values(array)

Parameter Values

Parameter Description
array Required. Specifying the array to count values of

Example :

 

Output : 

Array
(
    [web] => 2
    [designing] => 2
    [b] => 1
)