找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 php教程 查看内容

php substr_count函数怎么用

作者:模板之家 2019-5-25 09:18 3434人关注

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

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

<?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函数怎么用的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章!


路过

雷人

握手

鲜花

鸡蛋
来自: [db:来源]

全部回复(0)

发表评论