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선

음성 인공지능 스타트업의 기회 분석

인간 본성의 법칙 (책 리뷰 + 잡담)

CTC 손실 함수