php substr_count函数怎么用-php教程

资源魔 19 0
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函数怎样用的具体内容,更多请存眷资源魔其它相干文章!

标签: php开发教程 php开发资料 php开发自学 php substr_count

抱歉,评论功能暂时关闭!