similar_text

similar_text

similar_text

similar_text

-  It Calculate the similarity between two strings

Syntax:

int similar_text ( string first, string second [, float percent])

It calculates the similarity between two strings. This recursive calls which may or may not speed up the whole process. Note also that the complexity of this algorithm is O(N**3) where N is the length of the longest string.

By passing a reference as third argument, similar_text() will calculate the similarity in percent for you. It returns the number of matching chars in both strings.

Example:

echo similar_text(”xyz”,”abcd”);

it returns 0. because here, no matching or similar letters found in these parameter.

echo similar_text(”test”,”text”);

it returns 3. because here, there are 3 letters are similar between these parameter.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.