mardi 4 juin 2019

Multiple lines if statements

I am checking around 20 variables like the following and I was wondering if there is a faster way (less lines) to do the same:

if ($data1 == 1) {
  $res1 = "Yes";
} else {
  $res1 = "No";
}
if ($data2 == 1) {
  $res2 = "Yes";
} else {
  $res2 = "No";
}
if ($data3 == 1) {
  $res3 = "Yes";
} else {
  $res3 = "No";
}
etc..

Aucun commentaire:

Enregistrer un commentaire