导航首页 » 技术教程 » PHP:mb_substr_count()的用法_mbstring函数
PHP:mb_substr_count()的用法_mbstring函数 138 2023-12-12   

mb_substr_count

(PHP 4 >= 4.3.0, PHP 5)

mb_substr_count — 统计字符串出现的次数

说明

int mb_substr_count ( string $haystack , string $needle [, string $encoding = mb_internal_encoding() ] )

统计子字符串 needle 出现在字符串 haystack 中的次数。

参数

haystack

要检查的字符串。

needle

待查找的字符串。

encoding

encoding 参数为字符编码。如果省略,则使用内部字符编码。

返回值

子字符串 needle 出现在字符串 haystack 中的次数。

范例

Example #1 mb_substr_count() 例子

<?php
echo mb_substr_count("This is a test", "is"); // 输出 2
?>

参见

mb_strpos() - 查找字符串在另一个字符串中首次出现的位置 mb_substr() - 获取字符串的部分 substr_count() - 计算字串出现的次数


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103