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]
$arrayUtils->countValues() : ArrayUtils;
- A associative array of values from array as keys and their count as value.
$arrayUtils->countValuesAs() : array;
ArrayUtils::countValuesFrom(iterable $from) : ArrayUtils;
ArrayUtils::countValuesFromAs(iterable $from) : array;
Last modified 2yr ago