anyone has any idea if i can find a script that can show me how much two words are alike. example: cssBeauty <-> csdBaeuty ,and the result sould be in %
p.s. it's not too hard to be done, i could make it, but hey why not use one ready made. Mike
You would need a dictionary or library to compare words with.
Unless you want to assign the alphabet depth (percentage) and calculate a percentage based on what letters are what (ie. a -> b, 1 letter off, 3.85% wrong, 96.15% accurate) and how many are wrong.
Of course, you wouldn't know "how many are wrong" or "how far off" without a dictionary.
Here is exactly what i need this for, i have a database with names, and visitors must be able to search through the names in order to find out more details about the person. Can i use the database as a dictionary ? Something like spell-check as you mentioned, but it's with names. 10x for the links.
Are they seperated into first and last name fields in the database?
You could use something like metaphone() to search for similar phonetic matches, but the longer the text string you feed into it the less likely things are to match up.
Why not just use a MySQL query with wild cards and MATCH and AGAINST
$query = mysql_query("SELECT *, MATCH (`firstName`, `lastName`) AGAINST ('%" . $_GET['search'] . "%') AS `rating` FROM `namesList` WHERE MATCH (`firstName`, `lastName`) AGAINST ('%" . $_GET['search'] . "%') ORDER BY `rating` DESC");
Or something like that. My example was a bit excessive but you get the idea.