PHP substr_count() 函数

定义和用法

substr_count() 函数计算子串在字符串中出现的次数。

语法

substr_count(string,substring,start,length)
参数 描述
string 必需。规定要检查的字符串。
substring 必需。规定要检索的字符串。
start 可选。规定在字符串中何处开始搜索。
length 可选。规定搜索的长度。

例子

<?php
echo substr_count("Hello world. The world is nice","world");
?>

输出:

2
系统帮助 | 给我留言 | 收藏本站
Copyright © 2005-2008 www.cnn84.com All Rights Reserved Ver:2.0
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南