How can I use PHP to find the closest match?
Posted on 2009-12-30
Due to some naming convention inconsistencies, I'm in a situation where I have a list of company names that I pulled from a database and an array of [alleged] matching companies.
I'm aware of the levenshtein() function, but that compares the characters, not the words as a whole. I need to make sure that when a word matches, it is given more weight than a similar matching word that is not exact.
For example, ABC Technology should match ABC Technologies in whatever solution you experts suggest.
Using levenshtein(), however, CBAtechnolygo would be a better match than 'ABC Technologies' because it is closer in letters instead of words.
Hopefully this makes sense. Does PHP have any functions that can help me with this problem?