Definitions and examples of statistical word count functions implemented by php, Word Count examples
This document describes how to define and use the statistical wordcount function implemented by php. We will share this with you for your reference. The details are as follows:
<? Php // function Definition: function countWords ($ str) {echo (mb_strlen ($ str, 'utf8') + strlen ($ str)/2;} // usage: $ strdemo1 = 'Welcome to the house'; $ strdemo2 = 'HTTP: // www.bkjia.com '; $ strdemo3 = 'Welcome to the house' http://www.bkjia.com; countWords ($ strdemo1 ); echo "<br/>"; countWords ($ strdemo2); echo "<br/>"; countWords ($ strdemo3);?>
Running result:
161935
PS: here we recommend two very convenient statistical tools for your reference:
Online word count statistics tools:
Http://tools.jb51.net/code/zishutongji
Online character statistics and editing tools:
Http://tools.jb51.net/code/char_tongji