Forum Moderators: coopster
$array = array('red', 'red', 'red', 'green', 'blue');
I want to transform this into an associative array that lists the color value, and how many of each color values were in the array. So it would look like this.
Array
(
['red'] => 3
['blue'] => 1
['green'] => 1
)
How would I go about doing that?
Basically, I have a list of string values in an array. I want to output each string value (avoiding duplicates), and I want to output the amount of each value found within the array.
For example:
List
----
Red [3]
Blue [1]
Green [1]
Grey [5]
Black [2]