jeudi 6 avril 2017

nested if-else statement with same else code

I have the following code and want to know if there is a better way to use the if-else with same result other than using the same else three times?

if($condition1) {
   // some code to get condition 2
   if($condition2) {
      // some code to get condition 3
      if($condition3) {
         $dt = $something;
      } else {
         $dt = "";
      }
   } else {
      $dt = "";
   }
} else {
   $dt = ""; 
}

Aucun commentaire:

Enregistrer un commentaire