Home >Backend Development >PHP Tutorial >A simple way to count the number of words in a string in php, count words in a string in php_PHP tutorial

A simple way to count the number of words in a string in php, count words in a string in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 09:49:371083browse

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:

<&#63;php 
  function word_count($sentence){ 
    $array = explode(" ", $sentence); 
    return count($array); 
  } 
  $words = word_count("The is a group of words"); 
  echo $words; 
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn