3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hasil = 12; $kecewa = array(0,10,12); $biasa = array(10,12,16); $puas = array(12,16,20); $kb = array_intersect($kecewa, $biasa); $bp = array_intersect($biasa, $puas); print_r($kb); print_r($bp); // antara 65 - 80 if ( $hasil >= $bp[1] && $hasil <= $bp[2] ) { $muBiasa = ($hasil >= $bp[2])? '0' : ($hasil - $bp[1]) / ($bp[2] - $bp[1]); $muPuas = ($hasil - $bp[1]) / ($bp[2] - $bp[1]); echo " muPuas " .$muPuas; echo " muBiasa " .$muBiasa; } // antara 40 - 65 elseif ( $hasil >= $kb[1] && $hasil < $kb[2] ) { $muKecewa = ($kb[2] - $hasil) / ($kb[2] - $kb[1]); $muBiasa = ($hasil - $kb[1]) / ($kb[2] - $kb[1]); echo "muKecewa " .$muKecewa; echo "muBias " .$muBiasa; }
Output for 4.3.0 - 7.1.0
Array ( [1] => 10 [2] => 12 ) Array ( [1] => 12 [2] => 16 ) muPuas 0 muBiasa 0