$n1 = similar_text($str1, $str1); $n2 = similar_text($str2, $str2); $nn = similar_text($str1, $str2); $per = $nn / (sqrt(($n1*$n1 + $n2*$n2)/2));