How to simply count the number of words in a string in php, how to count the number of words in a string in php
The example in this article describes how to simply count the number of words in a string in php. Share it with everyone for your reference. The specific implementation method is as follows:
<?php
function word_count($sentence){
$array = explode(" ", $sentence);
return count($array);
}
$words = word_count("The is a group of words");
echo $words;
?>
Copy after login
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/1019443.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1019443.htmlTechArticleHow to simply count the number of string words in php, php counts string words This article describes the simple counting of strings in php word count method. Share it with everyone for your reference. Specific actual...