PHP similar_text algorithm

The similar_text returns the number of matching letters of two strings. It can also calculate the similarity of the two strings in percent (matched letters count/average length of two letters)*100. For example,

echo similar_text("Hello World","Hello Peter");
Output: 7

echo similar_text("Pello World","Hello Weter");
Output: 6, because the letters are not in the correct order.

similar_text("Hello World","Hello Peter",$percent);
echo $percent;
Output: 63.6363636364


Popular posts from this blog

일본만화 추천 100선

AWS re:Invent 2017 참관기

조직 관성(Organizational Inertia)