Find the number of words in a string:
In PHP, to find number of words in a string a function str_word_count() is used. It includes three parameters:
- string: It a required parameter which specify the string to check.
- return:It is an optional parameter that specify the return value.
- char: It is also an optional parameter that specify special character to be considered as words.
Syntax:
str_word_count(string,return,char)
Returns a number or array that depends upon the chosen return parameter. The default value is 0 i.e., the number of words found.
Find the length of a string:
To find length of a string a function strlen() is used. It includes one parameter which is the string whose length you want to find.
Syntax:
strlen(string)
0 Comment(s)