i'm creating a jquery tagcloud in a php site. in my mysql db i have a 'tags' field where there will be a list of comma separated words. i want to produce an array of words with the frequency with which they appear. just to complicate things, the text will all be in hebrew (utf8 encoded).
in english this solution works perfectly :
$words = array_count_values(str_word_count($str, 1));
print_r($words);
taken from here php: sort and count instances of words in a given string
with hebrew text the array is not filled.
i found this post str_word_count() function doesn't display Arabic language properly and, while it works, it only gives a total count of the number of words, and doesn't create an array of results like the previous function does.
i'd like the results to look something like this :
Array
(
[happy] => 4
[beautiful] => 1
[lines] => 3
[pear] => 2
[gin] => 1
[rock] => 1
)
any suggestions?