PHP: Count-IF for Arrays

Posted by st4ck0v3rfl0w on Stack Overflow See other posts from Stack Overflow or by st4ck0v3rfl0w
Published on 2010-03-12T07:45:14Z Indexed on 2010/03/12 7:47 UTC
Read the original article Hit count: 264

Filed under:
|

Hi All,

What would be the most efficient way of counting the number of times a value appears inside an array?

Example Array ('apple','apple','banana','banana','kiwi')

Ultimately I want a function to spit out the percentages for charting purposes (e.g. apple = 40%, banana = 40%, kiwi = 20%)

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays