mb_substr_count

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_substr_count统计字符串出现的次数

说明

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

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

参数

haystack

要检查的字符串

needle

待查找的字符串

encoding

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

返回值

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

范例

Example #1 mb_substr_count() 例子

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

参见

相关文章
php iconv 函数 返回字符串的字符数统计php 多字节字符串 函数 为 mime 头编码字符串php 多字节字符串 函数 encode character to html numeric string referencephp 多字节字符串 函数 get aliases of a known encoding typephp 多字节字符串 函数 获取 mbstring 的内部设置php 多字节字符串 函数 检测 http 输入字符编码php 多字节字符串 函数 获取按指定宽度截断的字符串php 多字节字符串 函数 大小写不敏感地查找字符串在另一个字符串中首次出现的位置php 多字节字符串 函数 大小写不敏感地查找字符串在另一个字符串里的首次出现php 多字节字符串 函数 查找字符串在另一个字符串中首次出现的位置php 多字节字符串 函数 查找指定字符在另一个字符串中最后一次的出现php 多字节字符串 函数 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现php 多字节字符串 函数 大小写不敏感地在字符串中查找一个字符串最后出现的位置php 多字节字符串 函数 查找字符串在一个字符串中最后出现的位置php 多字节字符串 函数 查找字符串在另一个字符串里的首次出现php 多字节字符串 函数 统计字符串出现的次数php 字符串 函数 查找字符串首次出现的位置(不区分大小写)php 字符串 函数 查找字符串的首次出现php 字符串 函数 计算字串出现的次数php 多字节字符串 函数重载功能
关注编程学问公众号