3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hasil = 17; $kecewa = array(0,8,16); $biasa = array(8,16,20); $puas = array(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[2] ? ($hasil - $kb[1]) / ($kb[2] - $kb[1]) : "0.5" ); $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 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [1] => 8 [2] => 16 ) Array ( [1] => 16 [2] => 20 ) muPuas 0.25 muBiasa 1.125