I was just wondering if there is a shortcut to do something like this example :
if ( isset($_POST['name']) && $_POST['name'] == 'George' || $_POST['name'] == 'Mike' );
[EDIT] : Sorry if the question seemed ambiguous at first but what I meant to ask is “since I am doing all those checks on the same variable is there a better way not to write it three times?”
is there any easier way that is rare and ..
- cleaner than nesting.
- shorter than the syntax above?
- in any of (Ruby, C#, or PHP) since I mainly use those 3 languages.
This is just a general knowledge question, I was just getting bored of writing nested ifs or long logical operations like the one above.
You could define a function for getting post data:
The function will never show the notice about accessing a not existing array field and the result can be easily compared to the list of values in your example: