3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['Aloft', 4, 8.3, 24756], ['The bestian', 5, 8.0, 26553], ['The royal', 5, 8.2, 32226], ['Royal cariben', 5, 8.3, 33886], ['Kristal', 4, 8.1, 35551], ['Fiesta', 5, 8.2, 38221], ['Presidenta', 5, 8.3, 38500], ['The lagun amar', 5, 8.8, 41454], ['Casa Maya', 5, 8.1, 46518], ['Casa Magna', 4, 8.8, 47408], ['Americana', 5, 9.2, 59580], ]; $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 Aloft and The bestian... 22756 VS 26553 Aloft wins! ---------- Comparing Aloft and The royal... 26756 VS 32226 Aloft wins! ---------- Comparing Aloft and Royal cariben... 28756 VS 33886 Aloft wins! ---------- Comparing Aloft and Kristal... 20756 VS 35551 Aloft wins! ---------- Comparing Aloft and Fiesta... 26756 VS 38221 Aloft wins! ---------- Comparing Aloft and Presidenta... 28756 VS 38500 Aloft wins! ---------- Comparing Aloft and The lagun amar... 38756 VS 41454 Aloft wins! ---------- Comparing Aloft and Casa Maya... 24756 VS 46518 Aloft wins! ---------- Comparing Aloft and Casa Magna... 34756 VS 47408 Aloft wins! ---------- Comparing Aloft and Americana... 46756 VS 59580 Aloft wins! ---------- Comparing The bestian and The royal... 30553 VS 32226 The bestian wins! ---------- Comparing The bestian and Royal cariben... 32553 VS 33886 The bestian wins! ---------- Comparing The bestian and Kristal... 24553 VS 35551 The bestian wins! ---------- Comparing The bestian and Fiesta... 30553 VS 38221 The bestian wins! ---------- Comparing The bestian and Presidenta... 32553 VS 38500 The bestian wins! ---------- Comparing The bestian and The lagun amar... 42553 VS 41454 The lagun amar wins! ---------- Comparing The bestian and Casa Maya... 28553 VS 46518 The bestian wins! ---------- Comparing The bestian and Casa Magna... 38553 VS 47408 The bestian wins! ---------- Comparing The bestian and Americana... 50553 VS 59580 The bestian wins! ---------- Comparing The royal and Royal cariben... 34226 VS 33886 Royal cariben wins! ---------- Comparing The royal and Kristal... 26226 VS 35551 The royal wins! ---------- Comparing The royal and Fiesta... 32226 VS 38221 The royal wins! ---------- Comparing The royal and Presidenta... 34226 VS 38500 The royal wins! ---------- Comparing The royal and The lagun amar... 44226 VS 41454 The lagun amar wins! ---------- Comparing The royal and Casa Maya... 30226 VS 46518 The royal wins! ---------- Comparing The royal and Casa Magna... 40226 VS 47408 The royal wins! ---------- Comparing The royal and Americana... 52226 VS 59580 The royal wins! ---------- Comparing Royal cariben and Kristal... 25886 VS 35551 Royal cariben wins! ---------- Comparing Royal cariben and Fiesta... 31886 VS 38221 Royal cariben wins! ---------- Comparing Royal cariben and Presidenta... 33886 VS 38500 Royal cariben wins! ---------- Comparing Royal cariben and The lagun amar... 43886 VS 41454 The lagun amar wins! ---------- Comparing Royal cariben and Casa Maya... 29886 VS 46518 Royal cariben wins! ---------- Comparing Royal cariben and Casa Magna... 39886 VS 47408 Royal cariben wins! ---------- Comparing Royal cariben and Americana... 51886 VS 59580 Royal cariben wins! ---------- Comparing Kristal and Fiesta... 41551 VS 38221 Fiesta wins! ---------- Comparing Kristal and Presidenta... 43551 VS 38500 Presidenta wins! ---------- Comparing Kristal and The lagun amar... 53551 VS 41454 The lagun amar wins! ---------- Comparing Kristal and Casa Maya... 39551 VS 46518 Kristal wins! ---------- Comparing Kristal and Casa Magna... 49551 VS 47408 Casa Magna wins! ---------- Comparing Kristal and Americana... 61551 VS 59580 Americana wins! ---------- Comparing Fiesta and Presidenta... 40221 VS 38500 Presidenta wins! ---------- Comparing Fiesta and The lagun amar... 50221 VS 41454 The lagun amar wins! ---------- Comparing Fiesta and Casa Maya... 36221 VS 46518 Fiesta wins! ---------- Comparing Fiesta and Casa Magna... 46221 VS 47408 Fiesta wins! ---------- Comparing Fiesta and Americana... 58221 VS 59580 Fiesta wins! ---------- Comparing Presidenta and The lagun amar... 48500 VS 41454 The lagun amar wins! ---------- Comparing Presidenta and Casa Maya... 34500 VS 46518 Presidenta wins! ---------- Comparing Presidenta and Casa Magna... 44500 VS 47408 Presidenta wins! ---------- Comparing Presidenta and Americana... 56500 VS 59580 Presidenta wins! ---------- Comparing The lagun amar and Casa Maya... 27454 VS 46518 The lagun amar wins! ---------- Comparing The lagun amar and Casa Magna... 37454 VS 47408 The lagun amar wins! ---------- Comparing The lagun amar and Americana... 49454 VS 59580 The lagun amar wins! ---------- Comparing Casa Maya and Casa Magna... 56518 VS 47408 Casa Magna wins! ---------- Comparing Casa Maya and Americana... 68518 VS 59580 Americana wins! ---------- Comparing Casa Magna and Americana... 59408 VS 59580 Casa Magna wins! ---------- ---------- Top: Aloft: 10 The lagun amar: 9 The bestian: 8 Royal cariben: 7 The royal: 6 Presidenta: 5 Fiesta: 4 Casa Magna: 3 Americana: 2 Kristal: 1 Casa Maya: 0 ---------- Finalists: Aloft The lagun amar
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/dJBAf 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/dJBAf on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/dJBAf on line 3
Process exited with code 255.