str_word_count
mixed str_word_count ( string string [, int format [, string charlist]] )
Which is used to count the number of words inside the string and
the second parameter format of result.
If not specified returns the number of word in the given string
<?
$str = “Hai this is a test”;
//// will out put 5
echo str_word_count($str);
?>
if format is 1 then returns an array containing all the words found inside the string
<?
$str = “Hai this is a test”;
print_r(str_word_count($str,1));
?>
Array ( [0] => hai [1] => how [2] => are [3] => you )
if format is 2 then returns an associative array, where the key is the numeric position of the word inside the string and the value is the actual word itself
<?
$str = “Hai this is a test”;
print_r(str_word_count($str,2));
?>
Array ( [0] => hai [4] => how [8] => are [12] => you )
