PHP.nl

array_count_values

array_count_values

Counts the occurrences of each distinct value in an array

array **array_count_values** array $array
returns an array using

the values of (which must be integers or strings) as keys and their frequency in as values. array_count_values``array``array

arrayThe array of values to count

Returns an associative array of values from as keys and their count as value. array

Throws for every element which is not or . E_WARNING``string``int

Voorbeeld: example

<?php
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
?>
Array
(
    [1] => 2
    [hello] => 2
    [world] => 1
)

count``array_unique``array_values``count_chars