Your best bet are these:
- str_word_count — Return information about words used in a string
- array_count_values — Counts all the values of an array
Example
$words = 'A string with certain words occuring more often than other words.';
print_r( array_count_values(str_word_count($words, 1)) );
Output
Array
(
[A] => 1
[string] => 1
[with] => 1
[certain] => 1
[words] => 2
[occuring] => 1
[more] => 1
[often] => 1
[than] => 1
[other] => 1
)
marking CW because question is a duplicate of at least two other questions containing the same answer