views:

284

answers:

3

Hi, I'm looking for a library in PHP that will allow me to compare two strings, and determine if they similar. For example:

apple apple 100%
apple aple  80%

and so forth. any ideas?

+5  A: 

http://www.php.net/manual/en/function.similar-text.php

Does exactly that.

Dustin Hansen
+2  A: 

You might consider using the levenshtein, similar-text, soundex, or metaphone functions.

Michael
A: 

Also, if you're doing this comparison as a part of a data extraction from a database, many DB engines have a SOUNDS LIKE (or SOUNDEX) implementation. Doing this in the DB server would be faster than doing it in PHP.

Alex