使用substr_count()函數(shù)檢索字符出現(xiàn)的次數(shù),獲取指定字符在字符串中出現(xiàn)的次數(shù).
語法:substr_count(haystack,needle)
使用substr_count()函數(shù)獲取特定字符在字符串中出現(xiàn)的次數(shù)實例如下:
- <?php
- echo substr_count(“zero的php自學(xué)手冊”,”的”);
- echo “<br>”;
- echo substr_count(“www.111cn.net”,”o”);
- echo “<br>”;
- echo substr_count(“1033114118′,”1′);
- ?>
- //實例結(jié)果:
- //1
- //2
- //5
參數(shù) 描述
string 必需。規(guī)定要檢查的字符串。
replacement 必需。規(guī)定要插入的字符串。
start 可選。規(guī)定在字符串中何處開始搜索。
charlist 可選。規(guī)定搜索的長度.
新聞熱點
疑難解答