Use str_word_count function in php to count number of words in string

How to find out total number of words in string variable.

str_word_count() function is used to count + get total number of words inside a complete string variable. With the help of this string function web developer can get number of words written in web pages and show them below the post as Word count. So here is the complete step by step tutorial for Use str_word_count function in php to count number of words in string.

android-project-download-code-button

How to Use str_word_count function in php to count number of words in string.

Code for str_word_count-function-demo.php file.

 <?php

$demo = "Android-Examples is the best website for php and android tutorials.";

echo "Total Number of words :",str_word_count($demo);

?>

Screenshot:

Use str_word_count function in php to count number of words in string

Click here to download Use str_word_count function in php to count number of words in string project.