countValues()

The countValues() method counts all the values of an array

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["a", "a", "a", "b", "c", "c", "d"]);

//General usage
$arrayUtils->countValues();
// expected output: ["a" => 3, "b" => 1, "c" => 2, "d" => 1]

Syntax

$arrayUtils->countValues() : ArrayUtils;

Return value

  • A associative array of values from array as keys and their count as value.

Polymorphism

$arrayUtils->countValuesAs() : array;
ArrayUtils::countValuesFrom(iterable $from) : ArrayUtils;
ArrayUtils::countValuesFromAs(iterable $from) : array;

References

Last updated