3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hasil = 16; $kurang = array(0,12); $cukup = array(12,16); $berlebih = array(16,20); $kc = array_intersect($kurang, $cukup); $cb = array_intersect($cukup, $berlebih); print_r($kc); print_r($cb); // antara 12-16 if ( $hasil >= $cb[1] && $hasil <= $cb[2] ) { $muCukup = ($hasil >= $cb[2]) ? "0" : ($hasil <= $cb[2] ? ($hasil - $kc[1]) / ($kc[2] - $kc[1]) : "0.5" ); $muBerlebih = ($hasil - $cb[1]) / ($cb[2] - $cb[1]); echo " muPuas " .$muBerlebih; echo " muBiasa " .$muCukup; } // antara 0-12 elseif ( $hasil >= $kc[1] && $hasil < $kc[2] ) { $muKurang = ($kc[2] - $hasil) / ($kc[2] - $kc[1]); $muCukup = ($hasil - $kc[1]) / ($kc[2] - $kc[1]); echo "muKecewa " .$muKurang; echo "muBias " .$muCukup; }
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Array ( [1] => 12 ) Array ( [1] => 16 ) Notice: Undefined offset: 2 in /in/t5WbB on line 14 Notice: Undefined offset: 2 in /in/t5WbB on line 23
Output for hhvm-3.10.0 - 3.12.0
Array ( [1] => 12 ) Array ( [1] => 16 ) Notice: Undefined index: 2 in /in/t5WbB on line 14 Notice: Undefined index: 2 in /in/t5WbB on line 23
Output for 4.3.0 - 5.2.17
Array ( [1] => 12 ) Array ( [1] => 16 ) Notice: Undefined offset: 2 in /in/t5WbB on line 14 Notice: Undefined offset: 2 in /in/t5WbB on line 23