您的位置 首页 php

php substr_count函数怎么用

php substr_count函数用于统计一个字符串,在另一个字符串中出现次数,其语法是substr_count(string,substring,start,length),参数string 必需,是规定被检查的字符串;substring 必需,规定要搜索的字符串。

php substr_count函数怎么用?

作用:统计一个字符串,在另一个字符串中出现次数

语法:

substr_count(string,substring,start,length)

参数:

string 必需。规定被检查的字符串。

substring 必需。规定要搜索的字符串。

start 可选。规定在字符串中何处开始搜索。

length 可选。规定搜索的长度。

说明:

计算子串在字符串中出现的次数。子串是区分大小写的。该函数不计数重叠的子串。如果 start 参数加上 length 参数大于字符串长度,则该函数生成一个警告。

php substr_count()函数使用示例1

<?phpecho 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函数怎么用的详细内容,更多请关注求知技术网其它相关文章!

文章来源:智云一二三科技

文章标题:php substr_count函数怎么用

文章地址:https://www.zhihuclub.com/4366.shtml

关于作者: 智云科技

热门文章

网站地图