echo "".count(explode(" ","Sushant Shivam Sumit"));
strlen('your strings here!');
echo substr_count("Hello world. The world is nice","world");
//result 2
<?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";
?>
$wordCount = str_word_count(file_get_contents('trial.txt'));
#Text must be in double-qoutes in brackets
echo str_word_count("Text goes here...");