String Word Count in PHP

String Word Count in PHP. In this program, we can print the count the number of words in PHP programming. The str word count() function is a PHP built-in function that returns information on words used in a string, such as the total number of words in the string, their positions in the text, and so on.

<?php
echo str_word_count("welcome to inlarn");
?>

 

Output:

3

String Count in Php

The str word count() function is a built-in PHP function that returns information on words used in a string such as the total number of words in the string, the positions of the words in the string, and so on. The number of words in the string $string is returned. This PHP built-in function is used to count the number of entries currently in the array. If the variable is assigned to an empty array, the function may return 0. In addition, for variables that are not set, the function returns 0.