← All built-ins / substr_count()

substr_count()

substr_count(string $haystack, string $needle): int

Parameters

NameTypeDescription
$haystackstringstring to search in
$needlestringsubstring to count

Return value

How many times $needle occurs in $haystack.

Example

echo substr_count("holy holy holy", "holy");
3

See also

strpos()preg_match_all()