str_word_count()

It return the number of words in a string

Example

<?php
echo “<pre>”;
print_r(str_word_count(‘It return the number of words in a string’));
?>

Output

9