3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['sistina', 4, 8.2, 31055], ['Agustino', 4, 8.3, 31555], ['Evrostars', 4, 8.1, 32178], ['Larovere', 4, 8.2, 33137], ['Rex', 4, 8.0, 33789], ['Ludovici', 4, 8.1, 33929], ['Guilio', 4, 8.4, 34208], ['NH', 4, 8.6, 34403], ['Napoleon', 4, 8.3, 34906], ['Bittiya', 4, 8.1, 35446], ['La redidenza', 4, 8.9, 37446], ]; $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 sistina and Agustino... 33055 VS 31555 Agustino wins! ---------- Comparing sistina and Evrostars... 29055 VS 32178 sistina wins! ---------- Comparing sistina and Larovere... 31055 VS 33137 sistina wins! ---------- Comparing sistina and Rex... 27055 VS 33789 sistina wins! ---------- Comparing sistina and Ludovici... 29055 VS 33929 sistina wins! ---------- Comparing sistina and Guilio... 35055 VS 34208 Guilio wins! ---------- Comparing sistina and NH... 39055 VS 34403 NH wins! ---------- Comparing sistina and Napoleon... 33055 VS 34906 sistina wins! ---------- Comparing sistina and Bittiya... 29055 VS 35446 sistina wins! ---------- Comparing sistina and La redidenza... 45055 VS 37446 La redidenza wins! ---------- Comparing Agustino and Evrostars... 27555 VS 32178 Agustino wins! ---------- Comparing Agustino and Larovere... 29555 VS 33137 Agustino wins! ---------- Comparing Agustino and Rex... 25555 VS 33789 Agustino wins! ---------- Comparing Agustino and Ludovici... 27555 VS 33929 Agustino wins! ---------- Comparing Agustino and Guilio... 33555 VS 34208 Agustino wins! ---------- Comparing Agustino and NH... 37555 VS 34403 NH wins! ---------- Comparing Agustino and Napoleon... 31555 VS 34906 Agustino wins! ---------- Comparing Agustino and Bittiya... 27555 VS 35446 Agustino wins! ---------- Comparing Agustino and La redidenza... 43555 VS 37446 La redidenza wins! ---------- Comparing Evrostars and Larovere... 34178 VS 33137 Larovere wins! ---------- Comparing Evrostars and Rex... 30178 VS 33789 Evrostars wins! ---------- Comparing Evrostars and Ludovici... 32178 VS 33929 Evrostars wins! ---------- Comparing Evrostars and Guilio... 38178 VS 34208 Guilio wins! ---------- Comparing Evrostars and NH... 42178 VS 34403 NH wins! ---------- Comparing Evrostars and Napoleon... 36178 VS 34906 Napoleon wins! ---------- Comparing Evrostars and Bittiya... 32178 VS 35446 Evrostars wins! ---------- Comparing Evrostars and La redidenza... 48178 VS 37446 La redidenza wins! ---------- Comparing Larovere and Rex... 29137 VS 33789 Larovere wins! ---------- Comparing Larovere and Ludovici... 31137 VS 33929 Larovere wins! ---------- Comparing Larovere and Guilio... 37137 VS 34208 Guilio wins! ---------- Comparing Larovere and NH... 41137 VS 34403 NH wins! ---------- Comparing Larovere and Napoleon... 35137 VS 34906 Napoleon wins! ---------- Comparing Larovere and Bittiya... 31137 VS 35446 Larovere wins! ---------- Comparing Larovere and La redidenza... 47137 VS 37446 La redidenza wins! ---------- Comparing Rex and Ludovici... 35789 VS 33929 Ludovici wins! ---------- Comparing Rex and Guilio... 41789 VS 34208 Guilio wins! ---------- Comparing Rex and NH... 45789 VS 34403 NH wins! ---------- Comparing Rex and Napoleon... 39789 VS 34906 Napoleon wins! ---------- Comparing Rex and Bittiya... 35789 VS 35446 Bittiya wins! ---------- Comparing Rex and La redidenza... 51789 VS 37446 La redidenza wins! ---------- Comparing Ludovici and Guilio... 39929 VS 34208 Guilio wins! ---------- Comparing Ludovici and NH... 43929 VS 34403 NH wins! ---------- Comparing Ludovici and Napoleon... 37929 VS 34906 Napoleon wins! ---------- Comparing Ludovici and Bittiya... 33929 VS 35446 Ludovici wins! ---------- Comparing Ludovici and La redidenza... 49929 VS 37446 La redidenza wins! ---------- Comparing Guilio and NH... 38208 VS 34403 NH wins! ---------- Comparing Guilio and Napoleon... 32208 VS 34906 Guilio wins! ---------- Comparing Guilio and Bittiya... 28208 VS 35446 Guilio wins! ---------- Comparing Guilio and La redidenza... 44208 VS 37446 La redidenza wins! ---------- Comparing NH and Napoleon... 28403 VS 34906 NH wins! ---------- Comparing NH and Bittiya... 24403 VS 35446 NH wins! ---------- Comparing NH and La redidenza... 40403 VS 37446 La redidenza wins! ---------- Comparing Napoleon and Bittiya... 30906 VS 35446 Napoleon wins! ---------- Comparing Napoleon and La redidenza... 46906 VS 37446 La redidenza wins! ---------- Comparing Bittiya and La redidenza... 51446 VS 37446 La redidenza wins! ---------- ---------- Top: La redidenza: 10 NH: 9 Agustino: 8 Guilio: 7 sistina: 6 Napoleon: 5 Larovere: 4 Evrostars: 3 Ludovici: 2 Bittiya: 1 Rex: 0 ---------- Finalists: La redidenza NH
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/HE6co 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/HE6co on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/HE6co on line 3
Process exited with code 255.