3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $sks = 11.5; $kecewa = array(0,8.5,14); $biasa = array(8.5,14,19.5); $puas = array(14,19.5,24); $kb = array_intersect($kecewa, $biasa); $bp = array_intersect($biasa, $puas); print_r($kb); print_r($bp); // antara 65 - 80 if ( $sks >= $bp[1] && $sks <= $bp[2] ) { $muBiasa = ($sks >= $bp[2]) ? "0" : ($sks <= $bp[2] ? ($sks - $kb[1]) / ($kb[2] - $kb[1]) : "0.5" ); $muPuas = ($sks - $bp[1]) / ($bp[2] - $bp[1]); echo " muPuas " .$muPuas; echo " muBiasa " .$muBiasa; } // antara 40 - 65 elseif ( $sks >= $kb[1] && $sks < $kb[2] ) { $muKecewa = ($kb[2] - $sks) / ($kb[2] - $kb[1]); $muBiasa = ($sks - $kb[1]) / ($kb[2] - $kb[1]); echo "muKecewa " .$muKecewa; echo "muBias " .$muBiasa; }
Output for 4.3.0 - 7.1.0
Array ( [1] => 8.5 [2] => 14 ) Array ( [1] => 14 [2] => 19.5 ) muKecewa 0.45454545454545muBias 0.54545454545455