substr_count
substr_count()是一个函式,用来计运算元串在字元串中出现的次数。
基本介绍
- 中文名:substr_count
- 类型:函式
- 作用:计运算元串在字元串中出现的次数
- 参数:string、replacement等
语法
substr_count(string,substring,start,length) |
参数 | 描述 |
string | 必需。规定要检查的字元串。 |
replacement | 必需。规定要插入的字元串。 |
start | 可选。规定在字元串中何处开始搜寻。 |
charlist | 可选。规定搜寻的长度。 |
例子
<?php echo substr_count("Hello world. The world is nice","world"); ?> |
输出:
2 |
PHP String 函式