PHP str_word_count() Function

P
PHP str_split() Function
PHP strcasecmp() Function

WHAT IS THE SYNTAX OF THE STR_WORD_COUNT() FUNCTION IN PHP?

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 found1 – Returns an array with the words from the string2 – 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 STR_WORD_COUNT() method

EXAMPLES OF THE STR_WORD_COUNT() FUNCTION

Example 1. In this example, we count the number of words found in the string “Hello World!”.

<?php
echo str_word_count("Hello world!");
?>
PHP str_split() Function
PHP strcasecmp() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z