PHP function substr_count()

Availability in PHP 4.0

Count the number of occurrences of a substring

Parameters

Parameter Data type Default value Note
$haystack string not String to search
$needle string not Substring to be searched
$offset int null, Offset from which to start counting
$length int null Maximum length after the specified offset to search for a substring. Print a warning if the offset plus length is greater than the length of the haystack.

Return values

int

This function returns an integer.

Other resources

Official substr-count documentation

Newsletter

Nejlepsi tipy a triky o PHP do Vaseho e-mailu. Clanky a novinky nejen ze sveta PHP a programovani.