How to find the number of words in a string in PHP
str_word_count()
The PHP str_word_count() function can be used to find the number of words in a string.
Let's check out an example to understand how this function basically works:
<?php $my_str = 'The quick brown fox jumps over the lazy dog.'; // Outputs: 9 echo str_word_count($my_str); ?>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the PHP
str_word_count()functionThe PHP
str_word_count()function can be used to find the number of words in a string.Let's check out an example to understand how this function basically works:
need an explanation for this answer? contact us directly to get an explanation for this answer