Re: counting words.
| From: | Philip Olson | Date: | Mon, 07 Apr 2003 00:37:53 +0000 |
| Subject: | Re: counting words. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142622@lists.php.net to get a copy of this message | ||
On Sun, 6 Apr 2003, Sebastian wrote:
> its very inaccurate, over 10 words off:
>
> $count = str_word_count(strip_tags($row[12]));
>
> this is closer but still off:
>
> $words = explode(' ', strip_tags($row[12]));
> $count = count($words);
Simply exploding on ' ' will typically be off because
some words are separated by double spaces, newlines,
tabs, etc. This is why using regular expressions on
whitespace is more accurate. This is also why there
are a million ways to get a word count :)
Regards,
Philip