90
PHP string str_word_count() Function
The str_word_count() is in-built function of PHP. It is used to return information about words used in a string or counts the number of words in a string.
Syntax:
Parameter | Description | Required/Optional |
---|---|---|
string | Specify the string to check. | Required. |
return | Specify the return value of the function. Values:
| Optional. |
Char | Specify characters. | Optional |
Example 1
Output:
Your string is:PHP TutorAspire By using str_word_count(): 2
Example 2
Output:
Your string is:PHP TutorAspire Array ( [0] => PHP [1] => TutorAspire )
Example 3
Output:
Array ( [0] => Hello [1] => PHP [2] => TutorAspire ) Array ( [0] => Hello [1] => PHP [2] => & [3] => TutorAspire )
Reference:
http://php.net/manual/en/function.str-word-count.php
Next TopicPHP String