php比较相似字符串的方法
更新时间:2015年06月05日 09:54:57 作者:企鹅不笨
这篇文章主要介绍了php比较相似字符串的方法,通过php中similar_text函数来实现字符串的相似性比较功能,需要的朋友可以参考下
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud)
(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun)
本文实例讲述了php比较相似字符串的方法。分享给大家供大家参考。具体分析如下:
这里通过php的similar_text函数比较两个字符串的相似性。
$word2compare = "stupid"; $words = array( 'stupid', 'stu and pid', 'hello', 'foobar', 'stpid', 'upid', 'stuuupid', 'sstuuupiiid', ); while(list($id, $str) = each($words)){ similar_text($str, $word2compare, $percent); print "Comparing '$word2compare' with '$str': "; print round($percent) . "%\n"; } /* Results: Comparing 'stupid' with 'stupid': 100% Comparing 'stupid' with 'stu and pid': 71% Comparing 'stupid' with 'hello': 0% Comparing 'stupid' with 'foobar': 0% Comparing 'stupid' with 'stpid': 91% Comparing 'stupid' with 'upid': 80% Comparing 'stupid' with 'stuuupid': 86% Comparing 'stupid' with 'sstuuupiiid': 71% */
希望本文所述对大家的php程序设计有所帮助。
相关文章
php+resumablejs实现的分块上传 断点续传功能示例
这篇文章主要介绍了php+resumablejs实现的分块上传 断点续传功能,结合实例形式分析了php+resumablejs文件传输的具体实现步骤与相关操作技巧,需要的朋友可以参考下2017-04-04
最新评论