The str_word_count() function used for counts the words in a string.
Syntax
str_word_count(string,format,charlist)
format - 0 - returns the number of words found
1 - returns an array containing all the words found inside the string
2 - 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
Example
echo str_word_count('Hello Dear');
Output
2
Copyright ©2022 coderraj.com. All Rights Reserved.