array_count_values in PHP

Syntax of array_count_values

array array_count_values(array array)

Returns an array whose elements’ keys are the input array’s values. The value of each key is the number of times that key appears in the input array as a value

Example of array_count_values

$array = array(1, "hello", 1, "world", "hello");
    [1] => 2
    [hello] => 2
    [world] => 1

Leave a Comment