0x09:確定字符串出現的頻率復制代碼 代碼如下: php /* * 確定字符串出現的頻率 * substr_count()返回一個字符串在另外一個字符串中出現的次數。其形式為: * int substr_count(string str,string substring [,int offset [,int length]]) * 可選參數offset和length指定字符串便宜(從便宜處開始嘗試匹配字符串)和字符串長度(從便宜開始搜索的長度) * 下面的例子確定了每個單詞在這個sentence中出現的次數 */ $talk= talk I am acertain that we could dominate mindshare in this space with our new product, extablishing a true synergy beteen the marketing and product development teams. We'll own this space in thress months. talk; echo " br/ $sentencearray=explode(" ", $talk); foreach ($sentencearray as $item) { echo "The word strong $item /strong appears(".substr_count($talk, $item).")times br/ }