Re: counting words.

From: Date: Sun, 06 Apr 2003 14:51:46 +0000
Subject: Re: counting words.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-142590@lists.php.net to get a copy of this message
Justin French wrote: > It depends on what you define as a word, but let's take the simple > approach of stripping HTML et al, and exploding the string on the > spaces, then counting the array of words: > > <? > $str = "This is my <b> text </b> that I want to count"; > $words = explode(' ', strip_tags($str)); > $count = count($words); I believe substr_count() is faster than that method. http://www.php.net/manual/en/function.substr-count.php Jome

« previous php.general (#142590) next »