Possible Duplicate:
php: sort and count instances of words in a given string
I am looking to write a php function which takes a string as input, splits it into words and then returns an array of words sorted by the frequency of occurence of each word.
What's the most algorithmically efficient way of accomplishing this ?
Your best bet are these:
str_word_count
— Return information about words used in a stringarray_count_values
— Counts all the values of an arrayExample
Output
marking CW because question is a duplicate of at least two other questions containing the same answer