3v4l.org

run code in 300+ PHP versions simultaneously
<?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"; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.280.0090.04412.36
5.4.270.0090.03712.36
5.4.260.0090.03812.36
5.4.250.0070.03912.36
5.4.240.0070.03512.36
5.4.230.0070.04412.36
5.4.220.0050.05612.35
5.4.210.0120.04812.35
5.4.200.0130.03612.35
5.4.190.0070.05412.35
5.4.180.0060.04412.35
5.4.170.0070.04612.36
5.4.160.0090.03412.36
5.4.150.0090.03512.35
5.4.140.0080.04712.04
5.4.130.0070.04712.02
5.4.120.0090.04011.98
5.4.110.0050.03911.98
5.4.100.0090.03911.98
5.4.90.0100.04511.98
5.4.80.0060.03811.98
5.4.70.0040.03811.98
5.4.60.0050.04011.98
5.4.50.0110.04011.98
5.4.40.0090.03511.97
5.4.30.0090.04711.96
5.4.20.0080.03711.96
5.4.10.0090.04511.96
5.4.00.0090.05311.45
5.3.280.0110.05012.71
5.3.270.0110.05012.72
5.3.260.0080.06112.72
5.3.250.0070.04512.72
5.3.240.0070.04312.72
5.3.230.0100.05012.71
5.3.220.0060.05712.68
5.3.210.0160.06912.68
5.3.200.0220.05512.68
5.3.190.0100.05012.68
5.3.180.0180.06412.68
5.3.170.0070.04412.67
5.3.160.0120.03512.67
5.3.150.0270.04112.67
5.3.140.0080.04212.66
5.3.130.0100.04112.66
5.3.120.0080.04412.66
5.3.110.0110.03712.66
5.3.100.0030.04212.12
5.3.90.0080.03912.08
5.3.80.0080.03712.07
5.3.70.0080.05612.07
5.3.60.0070.05312.07
5.3.50.0080.05112.00
5.3.40.0120.04912.00
5.3.30.0080.04511.94
5.3.20.0140.04511.70
5.3.10.0090.03311.67
5.3.00.0250.07911.66

preferences:
140.85 ms | 1394 KiB | 7 Q