php group array by value and count

Solutions on MaxInterview for php group array by value and count by the best coders in the world

showing results for - "php group array by value and count"
Leonie
08 May 2016
1$colors=array("red","red","red","blue","green");
2$colorsCount=array_count_values($colors);
3print_r($colorsCount);
4#Array
5#(
6#    [red] => 3
7#    [blue] => 1
8#    [green] => 1
9#)