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