Anti SPAM: PHP compare similar string/text (with sorting) 2014-11-02 17:08
/ / /
Anti SPAM: PHP compare similar string/text (with sorting)
PHP::similar_text will be defeated by shuffling the text sequence,
this function try to sort before compare similar string.
Note: This only considers "\n"(LF) as token,
you could add more delimiter/separator. (e.g. "space", "period")
代碼:
function compare_similar_str($var_1, $var_2)
{
$a1 = array();
$a2 = array();
$percent = 0;
// You could add more delimiter/separators to fit your need
$a1 = explode("\n", str_replace(' ', '', $var_1));
$a2 = explode("\n", str_replace(' ', '', $var_2));
sort($a1);
sort($a2);
$var_1 = implode('', $a1);
$var_2 = implode('', $a2);
similar_text($var_1, $var_2, $percent);
return intval($percent);
}
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀



