I have a database table with 3 columns; id, question and answer. On the front-end, I have a PHP application that shows questions to the user. The application would then compare the user input with the answer on the database.Using only PHP, how do I loosely compare user's input with the record on the database and pass it as correct even though it is not a strict match? For example:-Question: What is the structure of a water molecule?Answer on database: Hydrogen and oxygenAcceptable answers: Oxygen and hydrogen, hydrogen n oxygen, hydrogen & oxygen
Loosely compare user input with database record
php;mysql
Levenshtein, SoundeX and Metaphone functions could be helpful.You might need to break the original answers to words, in order to make a better comparison. Also taking out and, [space]n[space], & from both correct answers and the user input could lead you to a much better results.