What's the shortest and simplest way to do this?
For example:
$var = $_GET['something'];
// how to limit the value of $var to "10", "20", "30", "40",
// and "" for any other input ?
I mean is there a php helper function that can do this, without having to use 5 IFs ?
in_array
is suitable in this case:
if(!in_array($var, array("10", "20", "30", "40"))
{
// $var will be "" if it does not equal: "10", "20", "30", or "40"
$var = "";
}
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