Home >> PHP >> str_word_count() function in PHP

str_word_count() function in PHP

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

 

Post Your Comment

Next Questions
strcasecmp() function
strchr() function
strcmp() function
strcspn() function
strip_tags() function
stripslashes() function
stripos() function
stristr() function
strlen() function
strnatcasecmp() function
strnatcmp() function
strncasecmp() function
strncmp() function
strpbrk() function
strpos() function
strrchr() function
strrev() function
strripos() function
strrpos() function
strspn() function
strstr() function
strtok() function
strtolower() function
strtoupper() function
strtr() function

Copyright ©2022 coderraj.com. All Rights Reserved.