PDA

View Full Version : word count and character count


sabret00the
06-27-2005, 06:58 PM
how do you work it out, i thought it would just be
$wordcount = str_word_count($text);
$charcount = array_sum(count_chars($text));


but for whatever reason the data isn't quite right, is there another way to work this out?

filburt1
06-27-2005, 07:01 PM
how do you work it out, i thought it would just be
$wordcount = str_word_count($text);
$charcount = array_sum(count_chars($text));


but for whatever reason the data isn't quite right, is there another way to work this out?
Define "quite right." A word can be defined many ways.

count_chars() groups the number of times specific characters occur. If you just want a string's length, use strlen() instead.

sabret00the
06-27-2005, 09:48 PM
ok i have some text, Microsoft Words says 196 words, where as $wordcount as defined above gives 207

deathemperor
06-28-2005, 04:42 AM
I think it depends on how you regard as a word.