Here is a nifty little function for you, called substr_count(haystack, needle)
http://www.php.net/manual/function.substr-count.php
Now, it doesn't count words (per say) just the occurences of a string inside of a string. For example (from the php doc page)
<?
print substr_count("this is a string", "is");
?>
Will print out 2, 1 for the occurence of "is" in "this" and the other for the actual word "is". You will have to find a more complicated procedure to count actual words (split the string up, remove the extraneous characters (periods, exclamation points, etc) and then count how many times it occurs in that array).
Hope that helps!
Chris King