mercredi 4 décembre 2019

How to use if nested in PHP?

i have a problem regarding using if else nested in php, the $hasilkonsentrasi is unreadable, Thankyou

<div class="alert alert-info">
  <?php  
   if ($hasil[0] > $hasil[1]) {
    if ($hasil[0] > $hasil[2]) {
     if ($hasil[0] > $hasil[3]) {
     $hasilkonsentrasi = "Manajemen Keamanan Jaringan";
     }     
    }
   }
   elseif ($hasil[1] > $hasil[0]) {
    if ($hasil[1] > $hasil[2]) {
     if ($hasil[1] > $hasil[3]) {
      $hasilkonsentrasi = "Teknologi Cerdas";
     }
    }
   }
   elseif ($hasil[2] > $hasil[0]) {
    if ($hasil[2] > $hasil[1]) {
     if ($hasil[2] > $hasil [3]) {
      $hasilkonsentrasi = "Manajemen Bisnis";
     }

    }
   }
   elseif ($hasil[3] > $hasil[0]) {
    if ($hasil[3] > $hasil[1]) {
     if ($hasil[3] > $hasil[2]) {
      $hasilkonsentrasi = "Manajemen Data dan Informasi";
     }

    }
   }
   echo "Anda cocok mengambil konsentrasi <strong>$hasilkonsentrasi</strong>";


  $mkj= number_format($hasil[0], 2, '.', '');
  $tc=$hasil[1];
  $mb=$hasil[2];
  $mdi=$hasil[3];
  $jurusan=$hasilkonsentrasi;
  $user->SimpanHasilJurusan($mkj,$tc,$mb,$mdi,$jurusan);
  ?>
 </div>
</div>

Aucun commentaire:

Enregistrer un commentaire