0

take this 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 to return a result like this:

#liverpool = 2
#cafc = 2
#LUFC = 1 
ETC ETC

How do I do it?

codaddict
457k83 gold badges502 silver badges537 bronze badges
asked Apr 27, 2010 at 11:06
1
  • 7
    How exactly can you have array with the same key appearing twice in it? Commented Apr 27, 2010 at 11:09

1 Answer 1

2

You could use the array_count_values() function, with a bit of modifications to your array, as it only counts values, and not keys.

(As suggested in a comment to your question, anyway, you cannot have the same key several times in an array -- which means your array probably already has your items as values, and not keys)

answered Apr 27, 2010 at 11:09
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.