Hello,
Is there a way to shorten long IF statements like below:
if($searchPhoto != "I" and $searchPhoto != "Y" and $searchPhoto != "N"){ $do_searchPhoto = ""; }
Thank you kindly!
Peter
You can use switch(). It isnt necessarily shorter but probably more effective
switch($var) { case 'Value': Do this break; case 'Value2': Do this instead break; default: if none of the above do this break; }
not really much shorter but...
$array = array('I', 'Y', 'N'); if (!in_array($searchPhoto, $array)) {$do_searchPhoto = '';}