PHP查找子字符串出现次数的函数

substr_count(string,substring,start,length)
参数描述
string 必要参数。指定字符串对象
substring 必要参数。指定需要进行搜索的子字符串
start 可选参数。指定位于字符串中开始搜索的起始位置
length 可选参数。指定搜索的长度

<?php
echo substr_count("Hello world. The world is nice","world");
?>
上述代码将输出下面的结果:
2
posted @ 2017-01-08 23:18  天涯海角路  阅读(924)  评论(0)    收藏  举报