首页 / PHP / PHP之mb_substr_count
PHP之mb_substr_count
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PHP之mb_substr_count,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1683字,纯文字阅读大概需要3分钟。
内容图文
![PHP之mb_substr_count](/upload/InfoBanner/zyjiaocheng/1329/bbf60149d128432b96c4023819c764af.jpg)
mb_substr_count
- (PHP 4 >= 4.3.0, PHP 5, PHP 7)
- mb_substr_count — Count the number of substring occurrences
- mb_substr_count — 统计字符串出现的次数
Description
int mb_substr_count(
string $haystack,
string $needle[,
string $encoding = mb_internal_encoding()])//Counts the number of times the needle substring occurs in the haystack string.//统计子字符串 needle 出现在字符串 haystack 中的次数。
Parameters
haystack
- The string being checked.
- 要检查的字符串。
needle
- The string being found.
- 待查找的字符串。
encoding
- The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.
- encoding 参数为字符编码。如果省略,则使用内部字符编码。
Return Values
- The number of times the needle substring occurs in the haystack string.
- 子字符串 needle 出现在字符串 haystack 中的次数。
Examples
<?php
/**
* Created by PhpStorm.
* User: zhangrongxiang
* Date: 2018/1/31
* Time: 下午10:07
*/
echo
mb_substr_count
(
"This is a test"
,
"is"
) . PHP_EOL;// 输出 2echomb_substr_count("This is a test"," ") . PHP_EOL;// 输出 3echomb_substr_count("hello 中国! 中国 ! 中国! hello","中国") . PHP_EOL;//3echomb_substr_count("hello 中国! 中国 ! 中国! hello","中国","gbk") . PHP_EOL;//3echomb_substr_count("hello 中国! 中国 ! 中国! hello","中国","utf-8") . PHP_EOL;//3echomb_substr_count("hello 中国! 中国 ! 中国! hello","中国","ascii") . PHP_EOL;//3echo"strlen : " . mb_strlen("hello 中国! 中国 ! 中国! hello") . PHP_EOL;//24echo"mb_strlen : " . strlen("hello 中国! 中国 ! 中国! hello") . PHP_EOL;//40 = 8*3 + 16echosubstr_count("hello 中国! 中国 ! 中国! hello","中国") . PHP_EOL;//3echosubstr_count("hello 中国! 中国 ! 中国! hello","中国",2,10) . PHP_EOL;//1
文章参考
原文:https://www.cnblogs.com/zhangrxiang/p/8395139.html
内容总结
以上是互联网集市为您收集整理的PHP之mb_substr_count全部内容,希望文章能够帮你解决PHP之mb_substr_count所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。