3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['Ingles', 1, 8.0, 34026], ['Auto', 3, 8.2, 34247], ['Pincipal', 3, 8.0, 34787], ['Akto', 3, 8.1, 33551], ['Caledonian', 3, 8.1, 37579], ['Catalunia', 2, 8.2, 38690], ['Aktabecene', 2, 8.0, 39010], ['Sunotel', 4, 8.0, 39023], ['Gondal', 2, 8.0, 40009], ['Chik', 3, 8.2, 40817], ['Catalonia Avino', 3, 8.3, 41402], ['Kami', 0, 8.8, 41450], ['Konstantsa', 2, 8.8, 41938], ['Room', 3, 8.8, 42102], ['Redjesia', 3, 8.7, 42735], ]; $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 - 7.1.0
Comparing Ingles and Auto... 46026 VS 34247 Auto wins! ---------- Comparing Ingles and Pincipal... 42026 VS 34787 Pincipal wins! ---------- Comparing Ingles and Akto... 44026 VS 33551 Akto wins! ---------- Comparing Ingles and Caledonian... 44026 VS 37579 Caledonian wins! ---------- Comparing Ingles and Catalunia... 42026 VS 38690 Catalunia wins! ---------- Comparing Ingles and Aktabecene... 38026 VS 39010 Ingles wins! ---------- Comparing Ingles and Sunotel... 46026 VS 39023 Sunotel wins! ---------- Comparing Ingles and Gondal... 38026 VS 40009 Ingles wins! ---------- Comparing Ingles and Chik... 46026 VS 40817 Chik wins! ---------- Comparing Ingles and Catalonia Avino... 48026 VS 41402 Catalonia Avino wins! ---------- Comparing Ingles and Kami... 46026 VS 41450 Kami wins! ---------- Comparing Ingles and Konstantsa... 54026 VS 41938 Konstantsa wins! ---------- Comparing Ingles and Room... 58026 VS 42102 Room wins! ---------- Comparing Ingles and Redjesia... 56026 VS 42735 Redjesia wins! ---------- Comparing Auto and Pincipal... 30247 VS 34787 Auto wins! ---------- Comparing Auto and Akto... 32247 VS 33551 Auto wins! ---------- Comparing Auto and Caledonian... 32247 VS 37579 Auto wins! ---------- Comparing Auto and Catalunia... 30247 VS 38690 Auto wins! ---------- Comparing Auto and Aktabecene... 26247 VS 39010 Auto wins! ---------- Comparing Auto and Sunotel... 34247 VS 39023 Auto wins! ---------- Comparing Auto and Gondal... 26247 VS 40009 Auto wins! ---------- Comparing Auto and Chik... 34247 VS 40817 Auto wins! ---------- Comparing Auto and Catalonia Avino... 36247 VS 41402 Auto wins! ---------- Comparing Auto and Kami... 34247 VS 41450 Auto wins! ---------- Comparing Auto and Konstantsa... 42247 VS 41938 Konstantsa wins! ---------- Comparing Auto and Room... 46247 VS 42102 Room wins! ---------- Comparing Auto and Redjesia... 44247 VS 42735 Redjesia wins! ---------- Comparing Pincipal and Akto... 36787 VS 33551 Akto wins! ---------- Comparing Pincipal and Caledonian... 36787 VS 37579 Pincipal wins! ---------- Comparing Pincipal and Catalunia... 34787 VS 38690 Pincipal wins! ---------- Comparing Pincipal and Aktabecene... 30787 VS 39010 Pincipal wins! ---------- Comparing Pincipal and Sunotel... 38787 VS 39023 Pincipal wins! ---------- Comparing Pincipal and Gondal... 30787 VS 40009 Pincipal wins! ---------- Comparing Pincipal and Chik... 38787 VS 40817 Pincipal wins! ---------- Comparing Pincipal and Catalonia Avino... 40787 VS 41402 Pincipal wins! ---------- Comparing Pincipal and Kami... 38787 VS 41450 Pincipal wins! ---------- Comparing Pincipal and Konstantsa... 46787 VS 41938 Konstantsa wins! ---------- Comparing Pincipal and Room... 50787 VS 42102 Room wins! ---------- Comparing Pincipal and Redjesia... 48787 VS 42735 Redjesia wins! ---------- Comparing Akto and Caledonian... 33551 VS 37579 Akto wins! ---------- Comparing Akto and Catalunia... 31551 VS 38690 Akto wins! ---------- Comparing Akto and Aktabecene... 27551 VS 39010 Akto wins! ---------- Comparing Akto and Sunotel... 35551 VS 39023 Akto wins! ---------- Comparing Akto and Gondal... 27551 VS 40009 Akto wins! ---------- Comparing Akto and Chik... 35551 VS 40817 Akto wins! ---------- Comparing Akto and Catalonia Avino... 37551 VS 41402 Akto wins! ---------- Comparing Akto and Kami... 35551 VS 41450 Akto wins! ---------- Comparing Akto and Konstantsa... 43551 VS 41938 Konstantsa wins! ---------- Comparing Akto and Room... 47551 VS 42102 Room wins! ---------- Comparing Akto and Redjesia... 45551 VS 42735 Redjesia wins! ---------- Comparing Caledonian and Catalunia... 35579 VS 38690 Caledonian wins! ---------- Comparing Caledonian and Aktabecene... 31579 VS 39010 Caledonian wins! ---------- Comparing Caledonian and Sunotel... 39579 VS 39023 Sunotel wins! ---------- Comparing Caledonian and Gondal... 31579 VS 40009 Caledonian wins! ---------- Comparing Caledonian and Chik... 39579 VS 40817 Caledonian wins! ---------- Comparing Caledonian and Catalonia Avino... 41579 VS 41402 Catalonia Avino wins! ---------- Comparing Caledonian and Kami... 39579 VS 41450 Caledonian wins! ---------- Comparing Caledonian and Konstantsa... 47579 VS 41938 Konstantsa wins! ---------- Comparing Caledonian and Room... 51579 VS 42102 Room wins! ---------- Comparing Caledonian and Redjesia... 49579 VS 42735 Redjesia wins! ---------- Comparing Catalunia and Aktabecene... 34690 VS 39010 Catalunia wins! ---------- Comparing Catalunia and Sunotel... 42690 VS 39023 Sunotel wins! ---------- Comparing Catalunia and Gondal... 34690 VS 40009 Catalunia wins! ---------- Comparing Catalunia and Chik... 42690 VS 40817 Chik wins! ---------- Comparing Catalunia and Catalonia Avino... 44690 VS 41402 Catalonia Avino wins! ---------- Comparing Catalunia and Kami... 42690 VS 41450 Kami wins! ---------- Comparing Catalunia and Konstantsa... 50690 VS 41938 Konstantsa wins! ---------- Comparing Catalunia and Room... 54690 VS 42102 Room wins! ---------- Comparing Catalunia and Redjesia... 52690 VS 42735 Redjesia wins! ---------- Comparing Aktabecene and Sunotel... 47010 VS 39023 Sunotel wins! ---------- Comparing Aktabecene and Gondal... 39010 VS 40009 Aktabecene wins! ---------- Comparing Aktabecene and Chik... 47010 VS 40817 Chik wins! ---------- Comparing Aktabecene and Catalonia Avino... 49010 VS 41402 Catalonia Avino wins! ---------- Comparing Aktabecene and Kami... 47010 VS 41450 Kami wins! ---------- Comparing Aktabecene and Konstantsa... 55010 VS 41938 Konstantsa wins! ---------- Comparing Aktabecene and Room... 59010 VS 42102 Room wins! ---------- Comparing Aktabecene and Redjesia... 57010 VS 42735 Redjesia wins! ---------- Comparing Sunotel and Gondal... 31023 VS 40009 Sunotel wins! ---------- Comparing Sunotel and Chik... 39023 VS 40817 Sunotel wins! ---------- Comparing Sunotel and Catalonia Avino... 41023 VS 41402 Sunotel wins! ---------- Comparing Sunotel and Kami... 39023 VS 41450 Sunotel wins! ---------- Comparing Sunotel and Konstantsa... 47023 VS 41938 Konstantsa wins! ---------- Comparing Sunotel and Room... 51023 VS 42102 Room wins! ---------- Comparing Sunotel and Redjesia... 49023 VS 42735 Redjesia wins! ---------- Comparing Gondal and Chik... 48009 VS 40817 Chik wins! ---------- Comparing Gondal and Catalonia Avino... 50009 VS 41402 Catalonia Avino wins! ---------- Comparing Gondal and Kami... 48009 VS 41450 Kami wins! ---------- Comparing Gondal and Konstantsa... 56009 VS 41938 Konstantsa wins! ---------- Comparing Gondal and Room... 60009 VS 42102 Room wins! ---------- Comparing Gondal and Redjesia... 58009 VS 42735 Redjesia wins! ---------- Comparing Chik and Catalonia Avino... 42817 VS 41402 Catalonia Avino wins! ---------- Comparing Chik and Kami... 40817 VS 41450 Chik wins! ---------- Comparing Chik and Konstantsa... 48817 VS 41938 Konstantsa wins! ---------- Comparing Chik and Room... 52817 VS 42102 Room wins! ---------- Comparing Chik and Redjesia... 50817 VS 42735 Redjesia wins! ---------- Comparing Catalonia Avino and Kami... 39402 VS 41450 Catalonia Avino wins! ---------- Comparing Catalonia Avino and Konstantsa... 47402 VS 41938 Konstantsa wins! ---------- Comparing Catalonia Avino and Room... 51402 VS 42102 Room wins! ---------- Comparing Catalonia Avino and Redjesia... 49402 VS 42735 Redjesia wins! ---------- Comparing Kami and Konstantsa... 49450 VS 41938 Konstantsa wins! ---------- Comparing Kami and Room... 53450 VS 42102 Room wins! ---------- Comparing Kami and Redjesia... 51450 VS 42735 Redjesia wins! ---------- Comparing Konstantsa and Room... 45938 VS 42102 Room wins! ---------- Comparing Konstantsa and Redjesia... 43938 VS 42735 Redjesia wins! ---------- Comparing Room and Redjesia... 40102 VS 42735 Room wins! ---------- ---------- Top: Room: 14 Redjesia: 13 Konstantsa: 12 Auto: 11 Akto: 10 Pincipal: 9 Sunotel: 8 Catalonia Avino: 7 Caledonian: 6 Chik: 5 Kami: 4 Catalunia: 3 Ingles: 2 Aktabecene: 1 Gondal: 0 ---------- Finalists: Room Redjesia
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/s7gRn 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/s7gRn on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/s7gRn on line 3
Process exited with code 255.