mb_substr_count 统计字符串出现的次数

发表日期:2021-07-01 08:55:54 | 来源: | | 浏览(414) 分类:多字节字符串 函数

mb_substr_count

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

mb_substr_count统计字符串出现的次数

说明

mb_substr_count(string $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?>

参见

集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。