str_word_count

str_word_count(string,return,char)
ParameterDescription
stringRequired. Specifies the string to check
returnOptional. Specifies the return value of the str_word_count() function.Possible
values:
0 – Default. Returns the number of words found
1 – Returns an array with the words from the string
2 – Returns an array where the key is the position of the word in the string, and value is the actual word
charOptional. Specifies special characters to be considered as words.
<?php

print_r(str_word_count("Hello world!"));

print_r(str_word_count("Hello world!",1));


print_r(str_word_count("Hello world!",2));

print_r(str_word_count("Hello world & good morning!",1));

print_r(str_word_count("Hello world & good morning!",1,"&"));

?>


Leave a Reply