例如 : 单词 man 字符串 : now a man ,then comes so many men here.计算 man 在字符串中出现的次数 men 也算进去
相当于 man 在字符串中出现了两次.先谢谢了
相当于 man 在字符串中出现了两次.先谢谢了
解决方案 »
- 2010年LAMP兄弟连新版视频索引[不断更新中...]
- Fatal error: Class '_obfuscate_dg' not found in F:\libo\lm\show.php on line 14
- 问个关于 采集的问题
- 关于exec()的一点小问题
- 有关wordpress通过php来调用javascript
- 各位我下面是用Thinkphp开发的,帮看下
- 最近开发zen cart有些问题想咨询下!
- 正则表达式
- php调用sphinx提示failed to send client protocol version
- 请高手帮我吧原文弄出来,我整的很久也没搞出来
- zend studio可视化插件
- PHP获取客户端IP是127.0.0.1 ,什么原因?
那就没有办法了,除非你做一个字典,这个字有哪些也需要算进去的。
$str = 'now a man ,then comes so many men here.';
$res = array_count_values(str_word_count($str, 1));
echo $res['men'] + $res['man'];
function countWords($str)
{
preg_match_all("/m[ae]n/",$str,$matches);
return count($matches);
}
$string = "now a man ,then comes so many men here.";
echo countWords($string);
function countWords($str)
{
preg_match_all("/[^a-zA-Z]m[ae]n[^a-zA-Z]/",$str,$matches);
return count($matches);
}
$string = "now a man ,then comes so many men here.";
echo countWords($string);