Word Count
This function allows you to quickly calculate how many words a string contains. Very useful for word processor scripts!
php
function wordcount($str) {
return count(explode(" ",$str));
}
// Example Usage:
$test = "This has four words.";
echo "There are " . wordcount($test) . " in that sentence";
?>