Tutorial :Compare text strings to see if they match (allow slight differences)


I'm trying to compare data from two sources.

ORIG Kick-Ass: Music From The Motion Picture  ALT Kick-A*s (Music from the Motion Picture)  ALT Kick-Ass: (Music from the Motion Picture)[Explicit]  ALT Kick-Ass: A dedication  

ALT 1 ALT 2 and ORIG are the same match. ALT 3 is a dummy result.

I need to verify that these have a match, is there any methods available to me within the PHP library. I was thinking of counting each individual character with count_chars, then comparing that do the ORIG string using a percentage match. However if its a short title it wouldn't work too well.

Do you have any ideas how I could verify that they match,




Well, there's always the levenshtein distance, but I'm not sure how ultimately useful that would be for you.

Could be worth a shot, though.


you could consider using edit distance


the php call:


it returns the number of changes you would have to make (insertions & deletions) to transform one string into another



You can try something like: Hamming distance

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »