$strText = "This is a test"; $wordcount = count(explode(" ",$strText)); echo "There are $wordcount words in $strText"; ?>