We have something like this:
switch ($name)
{
/** Prune **/
case 'prune':
echo 'Prune command: Deletes ALL of the messages from the chat.';
break;
/** Lock **/
case 'lock':
echo 'Lock command: Locks the chat, nobody can talk!';
break;
/** Unlock **/
case 'unlock':
echo 'Unlock command: Unlocks the chat, everybody can talk!';
break;
/** Broadcast **/
case 'broadcast':
echo 'Broadcast command: Send a general broadcast message.';
break;
/** If command not found, echo suggestions.. **/
default:
echo 'Command not found, try these: /prune, /lock, /unlock, /broadcast';
break;
}
We have a form that sends data, this data will be stored into a variable $name
.
A user stored the following word: prunne.
Obviously, it will go to case default.
But what I want to do is, IF word is similar to any of the available cases, suggest the user.
For example, case prunne,
will echo: Not found, did you mean Prune*?
How do I do it?