拿这个数组:
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 )
我想要返回这样的结果:
#liverpool = 2
#cafc = 2
#LUFC = 1
ETC ETC
我该怎么做?
答案 0 :(得分:2)
您可以使用array_count_values()
功能,对阵列进行一些修改,因为它只计算值,而不是键。
(正如您对问题的评论中所建议的,无论如何,您不能在数组中多次使用相同的密钥 - 这意味着您的数组可能已经将您的项目作为值,而不是密钥)