I am working on sorting some text, I want to count how many times a certain word occurs.
the text part like
I have no idea, you got some idea, we will work out some
idea, I have no idea, you got some idea, we will work out some idea, I have no idea,you got some idea, we will work
out some idea
how can I use php to count how many times “idea” occurred, like word “idea” occurred 9
I am confused on count and length.
Could someone give an example please? many thanks
Try the script below. str_word_count() will split the sentence into array of words, and array_count_values() will assign the number of times each of them appears.