str_word_count() returns the number of words in a string.
For example:
<?php echo str_word_count( "Hello, world!" ); // Displays 2 ?>/*from w w w .ja va2 s. c o m*/