3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['pataya', 3, 8.2, 8806], ['Areka', 3, 8.2, 11227], ['Serene', 4, 8.1, 13942], ['Intemate', 4, 8.0, 15307], ['Discovery', 4, 8.0, 15950], ['LK', 4, 8.2, 17773], ['Pulmann', 5, 8.0, 20562], ['Rebit', 4, 8.7, 20730], ['Avalon', 4, 8.5, 21280], ['Inn', 4, 8.4, 28983], ['Royal', 5, 8.1, 33000], ['Centara', 5, 8.4, 35732], ['Veyv', 5, 9.0, 41426], ]; $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.10.0 - 3.12.0, 7.0.0 - 7.1.0
Comparing pataya and Areka... 8806 VS 11227 pataya wins! ---------- Comparing pataya and Serene... 10806 VS 13942 pataya wins! ---------- Comparing pataya and Intemate... 8806 VS 15307 pataya wins! ---------- Comparing pataya and Discovery... 8806 VS 15950 pataya wins! ---------- Comparing pataya and LK... 12806 VS 17773 pataya wins! ---------- Comparing pataya and Pulmann... 12806 VS 20562 pataya wins! ---------- Comparing pataya and Rebit... 22806 VS 20730 Rebit wins! ---------- Comparing pataya and Avalon... 18806 VS 21280 pataya wins! ---------- Comparing pataya and Inn... 16806 VS 28983 pataya wins! ---------- Comparing pataya and Royal... 14806 VS 33000 pataya wins! ---------- Comparing pataya and Centara... 20806 VS 35732 pataya wins! ---------- Comparing pataya and Veyv... 32806 VS 41426 pataya wins! ---------- Comparing Areka and Serene... 13227 VS 13942 Areka wins! ---------- Comparing Areka and Intemate... 11227 VS 15307 Areka wins! ---------- Comparing Areka and Discovery... 11227 VS 15950 Areka wins! ---------- Comparing Areka and LK... 15227 VS 17773 Areka wins! ---------- Comparing Areka and Pulmann... 15227 VS 20562 Areka wins! ---------- Comparing Areka and Rebit... 25227 VS 20730 Rebit wins! ---------- Comparing Areka and Avalon... 21227 VS 21280 Areka wins! ---------- Comparing Areka and Inn... 19227 VS 28983 Areka wins! ---------- Comparing Areka and Royal... 17227 VS 33000 Areka wins! ---------- Comparing Areka and Centara... 23227 VS 35732 Areka wins! ---------- Comparing Areka and Veyv... 35227 VS 41426 Areka wins! ---------- Comparing Serene and Intemate... 11942 VS 15307 Serene wins! ---------- Comparing Serene and Discovery... 11942 VS 15950 Serene wins! ---------- Comparing Serene and LK... 15942 VS 17773 Serene wins! ---------- Comparing Serene and Pulmann... 15942 VS 20562 Serene wins! ---------- Comparing Serene and Rebit... 25942 VS 20730 Rebit wins! ---------- Comparing Serene and Avalon... 21942 VS 21280 Avalon wins! ---------- Comparing Serene and Inn... 19942 VS 28983 Serene wins! ---------- Comparing Serene and Royal... 17942 VS 33000 Serene wins! ---------- Comparing Serene and Centara... 23942 VS 35732 Serene wins! ---------- Comparing Serene and Veyv... 35942 VS 41426 Serene wins! ---------- Comparing Intemate and Discovery... 15307 VS 15950 Intemate wins! ---------- Comparing Intemate and LK... 19307 VS 17773 LK wins! ---------- Comparing Intemate and Pulmann... 19307 VS 20562 Intemate wins! ---------- Comparing Intemate and Rebit... 29307 VS 20730 Rebit wins! ---------- Comparing Intemate and Avalon... 25307 VS 21280 Avalon wins! ---------- Comparing Intemate and Inn... 23307 VS 28983 Intemate wins! ---------- Comparing Intemate and Royal... 21307 VS 33000 Intemate wins! ---------- Comparing Intemate and Centara... 27307 VS 35732 Intemate wins! ---------- Comparing Intemate and Veyv... 39307 VS 41426 Intemate wins! ---------- Comparing Discovery and LK... 19950 VS 17773 LK wins! ---------- Comparing Discovery and Pulmann... 19950 VS 20562 Discovery wins! ---------- Comparing Discovery and Rebit... 29950 VS 20730 Rebit wins! ---------- Comparing Discovery and Avalon... 25950 VS 21280 Avalon wins! ---------- Comparing Discovery and Inn... 23950 VS 28983 Discovery wins! ---------- Comparing Discovery and Royal... 21950 VS 33000 Discovery wins! ---------- Comparing Discovery and Centara... 27950 VS 35732 Discovery wins! ---------- Comparing Discovery and Veyv... 39950 VS 41426 Discovery wins! ---------- Comparing LK and Pulmann... 17773 VS 20562 LK wins! ---------- Comparing LK and Rebit... 27773 VS 20730 Rebit wins! ---------- Comparing LK and Avalon... 23773 VS 21280 Avalon wins! ---------- Comparing LK and Inn... 21773 VS 28983 LK wins! ---------- Comparing LK and Royal... 19773 VS 33000 LK wins! ---------- Comparing LK and Centara... 25773 VS 35732 LK wins! ---------- Comparing LK and Veyv... 37773 VS 41426 LK wins! ---------- Comparing Pulmann and Rebit... 30562 VS 20730 Rebit wins! ---------- Comparing Pulmann and Avalon... 26562 VS 21280 Avalon wins! ---------- Comparing Pulmann and Inn... 24562 VS 28983 Pulmann wins! ---------- Comparing Pulmann and Royal... 22562 VS 33000 Pulmann wins! ---------- Comparing Pulmann and Centara... 28562 VS 35732 Pulmann wins! ---------- Comparing Pulmann and Veyv... 40562 VS 41426 Pulmann wins! ---------- Comparing Rebit and Avalon... 16730 VS 21280 Rebit wins! ---------- Comparing Rebit and Inn... 14730 VS 28983 Rebit wins! ---------- Comparing Rebit and Royal... 12730 VS 33000 Rebit wins! ---------- Comparing Rebit and Centara... 18730 VS 35732 Rebit wins! ---------- Comparing Rebit and Veyv... 30730 VS 41426 Rebit wins! ---------- Comparing Avalon and Inn... 19280 VS 28983 Avalon wins! ---------- Comparing Avalon and Royal... 17280 VS 33000 Avalon wins! ---------- Comparing Avalon and Centara... 23280 VS 35732 Avalon wins! ---------- Comparing Avalon and Veyv... 35280 VS 41426 Avalon wins! ---------- Comparing Inn and Royal... 26983 VS 33000 Inn wins! ---------- Comparing Inn and Centara... 32983 VS 35732 Inn wins! ---------- Comparing Inn and Veyv... 44983 VS 41426 Veyv wins! ---------- Comparing Royal and Centara... 39000 VS 35732 Centara wins! ---------- Comparing Royal and Veyv... 51000 VS 41426 Veyv wins! ---------- Comparing Centara and Veyv... 47732 VS 41426 Veyv wins! ---------- ---------- Top: Rebit: 12 pataya: 11 Areka: 10 Avalon: 9 Serene: 8 LK: 7 Intemate: 6 Discovery: 5 Pulmann: 4 Veyv: 3 Inn: 2 Centara: 1 Royal: 0 ---------- Finalists: Rebit pataya
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Vb5BO 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/Vb5BO on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Vb5BO on line 3
Process exited with code 255.