ASPit - Totally ASP
Search PHPit

Use this textbox to search all the content on PHPit. Seperate keywords with a space.

  • Metro PCS
  • Find a Tax Attorney
  • Coin Collecting
  • audio cables
  • Online College Degrees

Word Count

This function allows you to quickly calculate how many words a string contains. Very useful for word processor scripts!

function wordcount($str) {
count(explode(" ",$str));

// Example Usage:
$test = "This has four words.";
"There are " . wordcount($test) . " in that sentence";
About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.

Dennis Pallett has written 5 tutorials, 2 FAQs, and 19 codesnippets.