echo "".count(explode(" ","Sushant Shivam Sumit"));
<?php
$str = "Shivam Sumit Sushu";
$c = 0;
$i = 0;
for ($i=0; $i < strlen($str); $i++) {
// echo "".$str[$i]."<br>";
if ($str[$i]==" ") {
$c += 1;
}
}
if ($str[$i - 1] != " ") {
$c += 1;
}
echo "Words in '$str' are $c";
?>
#Text must be in double-qoutes in brackets
echo str_word_count("Text goes here...");