The substr_count() function is used to count the number of sub-strings.
Syntax
substr_count(str,substr,begin,len)
Parameters
str − The string to check
substr − The string to search for
begin − Where to begin searching in the string
len − The length of the search
Return
The substr_count() function returns the number of times substring occurs in the string.
Example
The following is an example −
<?php $str = 'This is our example!'; echo strlen($str); echo "\n"; echo substr_count($str, 'our'); ?>
Output
20 1