UK[kaʊnt] US[kaʊnt]
n.Total number; count; charges; argument
v. Count; calculate the total; count...; important
Third person singular: counts Plural: counts Present participle: counting Past tense: counted Past participle: counted
php substr_count() function syntax
Function:Count the number of times a string appears in another string
Syntax: substr_count(string,substring,start,length)
Parameters:
Description | |
Required. Specifies the string to be checked. | |
Required. Specifies the string to search for. | |
Optional. Specifies where in the string to begin the search. | |
Optional. Specifies the length of the search. |
Description: Calculate the number of times a substring appears in a string. Substrings are case-sensitive. This function does not count overlapping substrings. This function generates a warning if the start parameter plus the length parameter is greater than the string length.
php substr_count() function example
<?php echo substr_count("I love php.I'm study in php.cn","php"); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
2
<?php $str = "This is php.cn test"; echo substr_count($str,"is",3,9); ?>
Run Instance»
Click the "Run Instance" button to view the online instance
Output:
1