Reputation: 10400
I have an array where I'm storing the bad and good string pairs. Ex.:
array(
"Man. United"=>"Manchester United",
"Bay. Munchen"=>"Bayern Munchen",
"Bay. Munich"=>"Bayern Munchen",
...
)
so in this case I'm using strtr
to replace the given string, but in this case I always have to add or remove data's from the array. Is there any way to store just the good names in one array and replace which is very similar? For me is much easier to build up the array with the good names.
Upvotes: 1
Views: 108
Reputation: 21531
You could use similar_text or one of the other functions mentioned in the see also section to try and correct them automatically, but won't be as accurate as if you list the spelling mistakes yourself.
*edit: levenshtein may also be a good one to try...
The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform str1 into str2.
Upvotes: 2