3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hasil = 65; $kecewa = array(0,40,65); $biasa = array(40,65,80); $puas = array(65,80,100); $kb = array_intersect($kecewa, $biasa); $bp = array_intersect($biasa, $puas); print_r($kb); print_r($bp); if ( $hasil <= $kb ) { // hitung nilai kecewa pake rumus fuzzy logic $muKecewa = ($kb[2] - $hasil) / ($kb[2] - $kb[1]); //output : 52,5 //$muBiasa = ($muKecewa <= 1) ? '1' : '0'; // output: bool(true)/ 0.5 echo "muKecewa ".$muKecewa; //echo "muBiasa".$muBiasa; } elseif ( $hasil <= $bp ) { $muBiasa = ($hasil - $kb[1]) / ($bp[1] - $kb[1]); $muPuas = ($muBiasa >= 1) ? '0.5' : '0'; echo "muBias".$muBiasa; }
Output for 4.3.0 - 5.6.26, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
Array ( [1] => 40 [2] => 65 ) Array ( [1] => 65 [2] => 80 ) muKecewa 0