vendredi 10 avril 2015

Multiple Switch statement

I'm having four selectlists (in breezingforms), which are called "OplKeuzeD1", "OplKeuzeD2", "OplKeuzeD3", "OplKeuzeD4".


All selectlists has multiple option values, some have the same optionvalues.


The PHPcode I'm using now to check if a value is selected in one of the selectlists is:



if($value["OplKeuzeD1"] == "OPTION" || $value["OplKeuzeD2"] == "OPTION" || $value["OplKeuzeD3"] == "OPTION" || $value["OplKeuzeD4"] == "OPTION"){
$option = "OPTION";
}

if($value["OplKeuzeD1"] == "OPTION2" || $value["OplKeuzeD2"] == "OPTION2" || $value["OplKeuzeD3"] == "OPTION2" || $value["OplKeuzeD4"] == "OPTION2"){
$option = "OPTION2";
}


Is there a way to do this in a Switch case to have less code?


Thanks very much!


Aucun commentaire:

Enregistrer un commentaire