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

WBOY
Release: 2016-07-13 09:49:37
Original
1063 people have browsed it

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;>
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template