substr_count(string,substring,start,length)
参数 | 描述 |
---|---|
string | 必要参数。指定字符串对象 |
substring | 必要参数。指定需要进行搜索的子字符串 |
start | 可选参数。指定位于字符串中开始搜索的起始位置 |
length | 可选参数。指定搜索的长度 |
<?php
echo substr_count("Hello world. The world is nice","world");
?>
上述代码将输出下面的结果:
2
substr_count(string,substring,start,length)
参数 | 描述 |
---|---|
string | 必要参数。指定字符串对象 |
substring | 必要参数。指定需要进行搜索的子字符串 |
start | 可选参数。指定位于字符串中开始搜索的起始位置 |
length | 可选参数。指定搜索的长度 |
<?php
echo substr_count("Hello world. The world is nice","world");
?>
上述代码将输出下面的结果:
2