Saturday, 15 June 2013

php - Switch case, case was not found, but similar to the other case, give suggestion -


We have something like this:

  switch ($ name) {/ ** trimmed ** / Case 'sort': 'echo resignation order: Deletes all messages from chat'. '; break; / ** Lock ** / Case 'lock': 'Lock command echo: Chat lock, no one can talk!'; break; / ** unlock ** / Case 'unlock': 'Unlock command echo: opens chat, everyone can talk!'; break; / ** broadcast ** / case 'broadcast': 'Broadcast command: Send a normal broadcast message.'; break; / ** If the command is not found, then echo the suggestion. ** / Default: Echo 'command not found, try them: / bread, / lock, unlock, / broadcast'; break; }   

We have a form that sends the data, this data will be stored in a variable $ name .

A user has the following word: prunne .

Obviously, it will be in the case of default.

But what do I have to do, if the word any

for example,

echo will be: not found, do you mean it? *

How can I do this?

I can tell you in the right direction:

< P> Is there a PHP function that can be used for your cause, there is a good example on that page.

There is more information about a related stack overflow question when your string is more than 255 characters:



No comments:

Post a Comment