mb_substr_count
PHP function
Edit on GitHub ✎
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
Count the number of substring occurrences
Description
mb_substr_count(string $haystack, string $needle, string|null $encoding = null): int
Counts the number of times the needle substring occurs in the haystack string.
Parameters
haystackThe
stringbeing checked.needleThe
stringbeing found.encodingParameter
Return Values
The number of times the needle substring occurs in the haystack string.
Changelog
| Version | Description |
|---|
Examples
mb_substr_count() example
php
<?php
echo mb_substr_count("This is a test", "is"); // prints out 2
?>