时间:2021-07-01 10:21:17 帮助过:35人阅读
php substr_count函数怎么用?
作用:统计一个字符串,在另一个字符串中出现次数
语法:
- substr_count(string,substring,start,length)
参数:
string 必需。规定被检查的字符串。
substring 必需。规定要搜索的字符串。
start 可选。规定在字符串中何处开始搜索。
length 可选。规定搜索的长度。
说明:
计算子串在字符串中出现的次数。子串是区分大小写的。该函数不计数重叠的子串。如果 start 参数加上 length 参数大于字符串长度,则该函数生成一个警告。
php substr_count()函数使用示例1
- <?php
- echo substr_count("I love php.I'm study in php.cn","php");
- ?>
输出:
- 2
php substr_count()函数使用示例2
- <?php
- $str = "This is php.cn test";
- echo substr_count($str,"is",3,9);
- ?>
输出:
- 1
以上就是php substr_count函数怎么用的详细内容,更多请关注Gxlcms其它相关文章!