I would like to know how to calculate the similarity, in percentage, between two strings with PHP?
For example:
- I have a gift for you!
- I want some of you gifts!
I would like to know how to calculate the similarity, in percentage, between two strings with PHP?
For example:
The best native form of PHP itself is this:
$var_1 = 'Eu tenho um presente pra vocês!';
$var_2 = 'Eu quero alguns presentes de vocês!';
similar_text($var_1, $var_2, $percentual);
echo $percentual;
// 73.529411764706
Demo: link