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/ }