Hello,
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
printf("The number of words in \"$sentence\" is: %d words.
", $sentence, str_word_count($sentence));
?>
I get the following output:
The number of words in "This is a stentence whose words are to be counted." is: 0 words.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
printf("The number of words in \"$sentence\" is: %f words.
", $sentence, str_word_count($sentence));
?>
I get the following output:
The number of words in "This is a stentence whose words are to be counted." is: 0.000000 words.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
printf("The number of words in \"$sentence\" is %s words.
", $sentence, str_word_count($sentence));
?>
I get the following output:
The number of words in "This is a stentence whose words are to be counted." is This is a stentence whose words are to be counted. words.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
echo "The number of words in \"$sentence\" is ".str_word_count($sentence). " words.
";
?>
I get the following correct output:
The number of words in "This is a stentence whose words are to be counted." is 10 words.
I thought the printf function was more powerful than the echo command. Does anyone have any comment? Why is the printf() function not displaying the number of words? It either displays 0 or 0.0000 or the entire string again, but never the correct number. I tried type casting to (int) but still didn't work.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
printf("The number of words in \"$sentence\" is: %d words.
", $sentence, str_word_count($sentence));
?>
I get the following output:
The number of words in "This is a stentence whose words are to be counted." is: 0 words.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
printf("The number of words in \"$sentence\" is: %f words.
", $sentence, str_word_count($sentence));
?>
I get the following output:
The number of words in "This is a stentence whose words are to be counted." is: 0.000000 words.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
printf("The number of words in \"$sentence\" is %s words.
", $sentence, str_word_count($sentence));
?>
I get the following output:
The number of words in "This is a stentence whose words are to be counted." is This is a stentence whose words are to be counted. words.
When I use this php code:
<?php
$sentence="This is a stentence whose words are to be counted.";
echo "The number of words in \"$sentence\" is ".str_word_count($sentence). " words.
";
?>
I get the following correct output:
The number of words in "This is a stentence whose words are to be counted." is 10 words.
I thought the printf function was more powerful than the echo command. Does anyone have any comment? Why is the printf() function not displaying the number of words? It either displays 0 or 0.0000 or the entire string again, but never the correct number. I tried type casting to (int) but still didn't work.