最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php比較相似字符串的方法

 更新時間:2015年06月05日 09:54:57   作者:企鵝不笨  
這篇文章主要介紹了php比較相似字符串的方法,通過php中similar_text函數(shù)來實現(xiàn)字符串的相似性比較功能,需要的朋友可以參考下

本文實例講述了php比較相似字符串的方法。分享給大家供大家參考。具體分析如下:

這里通過php的similar_text函數(shù)比較兩個字符串的相似性。

$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程序設(shè)計有所幫助。

相關(guān)文章

最新評論

江川县| 巴彦淖尔市| 西青区| 界首市| 台前县| 山东省| 丹江口市| 文成县| 海兴县| 丰台区| 吴忠市| 秀山| 白玉县| 莱西市| 历史| 锦屏县| 宣城市| 杭锦旗| 柳江县| 杭锦后旗| 巴南区| 河南省| 东乡族自治县| 内丘县| 枝江市| 玛沁县| 岳西县| 靖边县| 鄂尔多斯市| 甘孜县| 石家庄市| 施秉县| 富蕴县| 瑞昌市| 永德县| 庄河市| 平原县| 盐亭县| 盐池县| 五台县| 明水县|