I have a field to input your friend's name and search him up to add him as friend.
The problem is that if you are not sure how to spell his name like:
Kris instead of Chris for example.
I think the right way to do this is use RegEx but I don't know how...
How can I handle those kind of typos in PHP ?
(if it isn't possible in PHP then tell me how to do it in jQuery)
I think a regex is not a good approach to check for typos and similar strings. I would consider something like levenshtein - PHP even has a native function for that, levenshtein.
EDIT: Depending on what you're looking for, there are other algorithms too that are also native in PHP: soundex (although considered superseded by newer approaches like Double Metaphone), metaphone, similar_text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With