Answers for "php group array by value and count"

PHP
0

php group array by value and count

$colors=array("red","red","red","blue","green");
$colorsCount=array_count_values($colors);
print_r($colorsCount);
#Array
#(
#    [red] => 3
#    [blue] => 1
#    [green] => 1
#)
Posted by: Guest on December-05-2020

Browse Popular Code Answers by Language