← All built-ins / substr_count()
substr_count()
substr_count(string $haystack, string $needle): int
Parameters
| Name | Type | Description |
|---|---|---|
| $haystack | string | string to search in |
| $needle | string | substring to count |
Return value
How many times $needle occurs in $haystack.
Example
echo substr_count("holy holy holy", "holy");3