belongs to collection: PHP Miscellaneous
Find similarity of two strings in PHP
There is a function similar_text() in PHP, that can be used to find the similarity of two strings, this function accepts three parameters: 1) string1, 2) string2 and 3) percent, percent will have the percentage of the similar text.
$str1 = "Welcome @ IncludeHelp";
$str2 = "Welcome @ IncludeHelp";
$str3 = "Welcome atIncludeHelp";
//Here, $percent will store the percentage of the similarity
similar_text($str1, $str2, $percent);
echo "similarity b/w str1 and str2 is: $percent \n";
similar_text($str2, $str3, $percent);
echo "similarity b/w str2 and str3 is: $percent \n";
similarity b/w str1 and str2 is: 100
similarity b/w str2 and str3 is: 90.47619047619
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.