3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Villa', 4, 8.5, 40398], ['Uvala', 4, 8.3, 52126], ['Valmar', 4, 8.6, 53104], ['Grand Hotel', 4, 8.1, 59340], ['Neptun', 4, 8.8, 61444], ['Valamar', 4, 8.7, 62365], ['Ariston', 5, 8.8, 68937], ['Rixos', 5, 8.5, 70370], ['Butique', 5, 9.2, 79818], ]; $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 git.master, git.master_jit, rfc.property-hooks
Comparing Villa and Uvala... 36398 VS 52126 Villa wins! ---------- Comparing Villa and Valmar... 42398 VS 53104 Villa wins! ---------- Comparing Villa and Grand Hotel... 32398 VS 59340 Villa wins! ---------- Comparing Villa and Neptun... 46398 VS 61444 Villa wins! ---------- Comparing Villa and Valamar... 44398 VS 62365 Villa wins! ---------- Comparing Villa and Ariston... 50398 VS 68937 Villa wins! ---------- Comparing Villa and Rixos... 44398 VS 70370 Villa wins! ---------- Comparing Villa and Butique... 58398 VS 79818 Villa wins! ---------- Comparing Uvala and Valmar... 58126 VS 53104 Valmar wins! ---------- Comparing Uvala and Grand Hotel... 48126 VS 59340 Uvala wins! ---------- Comparing Uvala and Neptun... 62126 VS 61444 Neptun wins! ---------- Comparing Uvala and Valamar... 60126 VS 62365 Uvala wins! ---------- Comparing Uvala and Ariston... 66126 VS 68937 Uvala wins! ---------- Comparing Uvala and Rixos... 60126 VS 70370 Uvala wins! ---------- Comparing Uvala and Butique... 74126 VS 79818 Uvala wins! ---------- Comparing Valmar and Grand Hotel... 43104 VS 59340 Valmar wins! ---------- Comparing Valmar and Neptun... 57104 VS 61444 Valmar wins! ---------- Comparing Valmar and Valamar... 55104 VS 62365 Valmar wins! ---------- Comparing Valmar and Ariston... 61104 VS 68937 Valmar wins! ---------- Comparing Valmar and Rixos... 55104 VS 70370 Valmar wins! ---------- Comparing Valmar and Butique... 69104 VS 79818 Valmar wins! ---------- Comparing Grand Hotel and Neptun... 73340 VS 61444 Neptun wins! ---------- Comparing Grand Hotel and Valamar... 71340 VS 62365 Valamar wins! ---------- Comparing Grand Hotel and Ariston... 77340 VS 68937 Ariston wins! ---------- Comparing Grand Hotel and Rixos... 71340 VS 70370 Rixos wins! ---------- Comparing Grand Hotel and Butique... 85340 VS 79818 Butique wins! ---------- Comparing Neptun and Valamar... 59444 VS 62365 Neptun wins! ---------- Comparing Neptun and Ariston... 65444 VS 68937 Neptun wins! ---------- Comparing Neptun and Rixos... 59444 VS 70370 Neptun wins! ---------- Comparing Neptun and Butique... 73444 VS 79818 Neptun wins! ---------- Comparing Valamar and Ariston... 68365 VS 68937 Valamar wins! ---------- Comparing Valamar and Rixos... 62365 VS 70370 Valamar wins! ---------- Comparing Valamar and Butique... 76365 VS 79818 Valamar wins! ---------- Comparing Ariston and Rixos... 62937 VS 70370 Ariston wins! ---------- Comparing Ariston and Butique... 76937 VS 79818 Ariston wins! ---------- Comparing Rixos and Butique... 84370 VS 79818 Butique wins! ---------- ---------- Top: Villa: 8 Valmar: 7 Neptun: 6 Uvala: 5 Valamar: 4 Ariston: 3 Butique: 2 Rixos: 1 Grand Hotel: 0 ---------- Finalists: Villa Valmar

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.83 ms | 409 KiB | 8 Q