Visit Our UNIX and Linux User Community


array_count_values - Counts all the values of an array

array array_count_values (array $array) DESCRIPTION
array_count_values(3) returns an array using the values of $array as keys and their frequency in $array as values. PARAMETERS
o $array - The array of values to count RETURN VALUES
Returns an associative array of values from $array as keys and their count as value. ERRORS
/EXCEPTIONS Throws E_WARNING for every element which is not string or integer. EXAMPLES
Example #1 array_count_values(3) example <?php $array = array(1, "hello", 1, "world", "hello"); print_r(array_count_values($array)); ?> The above example will output: Array ( [1] => 2 [hello] => 2 [world] => 1 ) SEE ALSO
count(3), array_unique(3), array_values(3), count_chars(3). PHP Documentation Group ARRAY_COUNT_VALUES(3)

Featured Tech Videos