3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['Polirisos', 3, 8.2, 13032], ['Triton', 4, 8.6, 13032], ['Melisa', 3, 8.1, 16289], ['Panormo', 3, 8.9, 17593], ['Horizon', 3, 8.7, 17593], ['Aliantes', 3, 8.7, 20851], ['Kurifi', 4, 8.6, 21991], ['Mari', 3, 8.5, 22154], ['Astron', 3, 8.9, 22479], ]; $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo 'Comparing '.$hotels[$i][0].' and '.$hotels[$j][0].'...'."\r\n"; $starDifference = $hotels[$i][1]-$hotels[$j][1]; $ratingToCompensate = $starDifference*$starCoef; $rating = $hotels[$i][2]+$ratingToCompensate; $ratingDifference = ($rating-$hotels[$j][2])*10; $priceToCompensate = $ratingDifference*$ratingCoef; $price = round($hotels[$i][3]-$priceToCompensate); echo $price.' VS '.$hotels[$j][3]."\r\n"; if ( $price < $hotels[$j][3] ) { echo $hotels[$i][0].' wins!'."\r\n"; $hotels[$i][4]++; } else { echo $hotels[$j][0].' wins!'."\r\n"; $hotels[$j][4]++; } echo "\r\n".'----------'."\r\n"; } } usort($hotels, function($hotelA, $hotelB){ return $hotelB[4]-$hotelA[4]; }); echo "\r\n".'----------'."\r\n"; echo 'Top:'."\r\n\r\n"; for ( $i=0; $i<count($hotels); $i++ ) { echo $hotels[$i][0].': '.$hotels[$i][4]."\r\n"; } echo "\r\n".'----------'."\r\n"; echo 'Finalists:'."\r\n\r\n"; for ( $i=0; $i<=1; $i++ ) { echo $hotels[$i][0]."\r\n"; }
Output for 5.4.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Comparing Polirisos and Triton... 25032 VS 13032 Triton wins! ---------- Comparing Polirisos and Melisa... 11032 VS 16289 Polirisos wins! ---------- Comparing Polirisos and Panormo... 27032 VS 17593 Panormo wins! ---------- Comparing Polirisos and Horizon... 23032 VS 17593 Horizon wins! ---------- Comparing Polirisos and Aliantes... 23032 VS 20851 Aliantes wins! ---------- Comparing Polirisos and Kurifi... 25032 VS 21991 Kurifi wins! ---------- Comparing Polirisos and Mari... 19032 VS 22154 Polirisos wins! ---------- Comparing Polirisos and Astron... 27032 VS 22479 Astron wins! ---------- Comparing Triton and Melisa... -968 VS 16289 Triton wins! ---------- Comparing Triton and Panormo... 15032 VS 17593 Triton wins! ---------- Comparing Triton and Horizon... 11032 VS 17593 Triton wins! ---------- Comparing Triton and Aliantes... 11032 VS 20851 Triton wins! ---------- Comparing Triton and Kurifi... 13032 VS 21991 Triton wins! ---------- Comparing Triton and Mari... 7032 VS 22154 Triton wins! ---------- Comparing Triton and Astron... 15032 VS 22479 Triton wins! ---------- Comparing Melisa and Panormo... 32289 VS 17593 Panormo wins! ---------- Comparing Melisa and Horizon... 28289 VS 17593 Horizon wins! ---------- Comparing Melisa and Aliantes... 28289 VS 20851 Aliantes wins! ---------- Comparing Melisa and Kurifi... 30289 VS 21991 Kurifi wins! ---------- Comparing Melisa and Mari... 24289 VS 22154 Mari wins! ---------- Comparing Melisa and Astron... 32289 VS 22479 Astron wins! ---------- Comparing Panormo and Horizon... 13593 VS 17593 Panormo wins! ---------- Comparing Panormo and Aliantes... 13593 VS 20851 Panormo wins! ---------- Comparing Panormo and Kurifi... 15593 VS 21991 Panormo wins! ---------- Comparing Panormo and Mari... 9593 VS 22154 Panormo wins! ---------- Comparing Panormo and Astron... 17593 VS 22479 Panormo wins! ---------- Comparing Horizon and Aliantes... 17593 VS 20851 Horizon wins! ---------- Comparing Horizon and Kurifi... 19593 VS 21991 Horizon wins! ---------- Comparing Horizon and Mari... 13593 VS 22154 Horizon wins! ---------- Comparing Horizon and Astron... 21593 VS 22479 Horizon wins! ---------- Comparing Aliantes and Kurifi... 22851 VS 21991 Kurifi wins! ---------- Comparing Aliantes and Mari... 16851 VS 22154 Aliantes wins! ---------- Comparing Aliantes and Astron... 24851 VS 22479 Astron wins! ---------- Comparing Kurifi and Mari... 15991 VS 22154 Kurifi wins! ---------- Comparing Kurifi and Astron... 23991 VS 22479 Astron wins! ---------- Comparing Mari and Astron... 30154 VS 22479 Astron wins! ---------- ---------- Top: Triton: 8 Panormo: 7 Horizon: 6 Astron: 5 Kurifi: 4 Aliantes: 3 Polirisos: 2 Mari: 1 Melisa: 0 ---------- Finalists: Triton Panormo
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/GkmUL on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/GkmUL on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/GkmUL on line 3
Process exited with code 255.