php - How do I count occurences of items in an array -
take array:
array ( [#twitterwhites] => 0 [#lufc] => 0 [#football] => 0 [#liverpool] => 0 [#liverpool] => 0 [#espn] => 0 [#lufc] => 0 [#cafc] => 0 [#cafc] => 0 [#ocra] => 0 [#nra] => 0 [#2nd] => 0 [#secondamendment] => 0 [#scr] => 0 [#tc500] => 0 [#cpfc] => 0 [#mot] => 0 )
i want return result this:
#liverpool = 2 #cafc = 2 #lufc = 1 etc etc
how do it?
you use array_count_values()
function, bit of modifications array, counts values, , not keys.
(as suggested in comment question, anyway, cannot have same key several times in array -- means array has items values, , not keys)
Comments
Post a Comment