HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_count_values

Description

The array_count_values of Array for PHP counts all the values of an array.

Syntax

array_count_values(
    array $array
): array

Parameters

array

The array of values to count

Return

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

Examples

1 · array

<?

$array =
[
    0,
    20,
    "hello",
    0,
    1,
    20
];

$return = array_count_values($array);

print_r($return);
Array
(
    [0] => 2
    [20] => 2
    [hello] => 1
    [1] => 1
)