(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
mb_substr_count — 統計字符串出現的次數
$haystack
, string $needle
, string $encoding
= mb_internal_encoding()): int
統計子字符串 needle
出現在字符串 haystack
中的次數。
haystack
要檢查的字符串。
needle
待查找的字符串。
encoding
encoding
參數為字符編碼。如果省略或是 null
,則使用內部字符編碼。
子字符串 needle
出現在字符串 haystack
中的次數。
示例 #1 mb_substr_count() 例子
<?php
echo mb_substr_count("This is a test", "is"); // 輸出 2
?>