Jump to content


Photo

Counting the amount of words in a string?


  • Please log in to reply
1 reply to this topic

#1 craigbabe

craigbabe
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 16 April 2006 - 05:35 AM

All I can find is how many characters there is but I want words. Do you know how i can do this?
Happy Easter btw

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 16 April 2006 - 06:29 AM

PHP 4.3.0+ example:

$msg = "Hello world!";

echo str_word_count($msg); // displays 2
[a href=\"http://us2.php.net/manual/en/function.str-word-count.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.str-word-count.php[/a]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users