php中的substr_count函数如何用
php中的substr_count函数的用途:【substr_count(string,substring,start,length)】。substr_count函数用于运算指定字串在字符串中显现的次数。
php substr_count函数用于统计一个字符串,在另一个字符串中显现次数,其语法是substr_count(string,substring,start,length),参数string 必需,是规定被检查的字符串;substring 必需,规定要搜索的字符串。
(引荐教程:php视频教程)
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函数如何用的具体内容,更多请关注百分百源码网其它相关文章!