3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Cala', 3, 8.7, 6000], ['Ocean', 3, 8.2, 6150], ['Orchid', 3, 8.0, 7200], ['Ya', 3, 8.7, 6950], ['Chaba', 3, 8.2, 7120], ]; $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo $j.' - '.$hotels[$j][0]; 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]; $priceToCompensate = $ratingDifference*$ratingCoef; $price = $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
1 - OceanComparing Cala and Ocean... 5000 VS 6150 Ocean wins! Warning: Undefined array key 4 in /in/aX9PN on line 39 ---------- 2 - OrchidComparing Cala and Orchid... 4600 VS 7200 Orchid wins! Warning: Undefined array key 4 in /in/aX9PN on line 39 ---------- 3 - YaComparing Cala and Ya... 6000 VS 6950 Ya wins! Warning: Undefined array key 4 in /in/aX9PN on line 39 ---------- Warning: Trying to access array offset on value of type int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on value of type int in /in/aX9PN on line 23 Comparing Cala and ... Warning: Trying to access array offset on value of type int in /in/aX9PN on line 25 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 29 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 33 -12600 VS Warning: Trying to access array offset on value of type int in /in/aX9PN on line 34 Cala wins! Warning: Undefined array key 4 in /in/aX9PN on line 36 ---------- 2 - OrchidComparing Ocean and Orchid... 5750 VS 7200 Orchid wins! ---------- 3 - YaComparing Ocean and Ya... 7150 VS 6950 Ocean wins! ---------- Warning: Trying to access array offset on value of type int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on value of type int in /in/aX9PN on line 23 Comparing Ocean and ... Warning: Trying to access array offset on value of type int in /in/aX9PN on line 25 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 29 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 33 -11450 VS Warning: Trying to access array offset on value of type int in /in/aX9PN on line 34 Ocean wins! ---------- 3 - YaComparing Orchid and Ya... 8600 VS 6950 Orchid wins! ---------- Warning: Trying to access array offset on value of type int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on value of type int in /in/aX9PN on line 23 Comparing Orchid and ... Warning: Trying to access array offset on value of type int in /in/aX9PN on line 25 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 29 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 33 -10000 VS Warning: Trying to access array offset on value of type int in /in/aX9PN on line 34 Orchid wins! ---------- Warning: Trying to access array offset on value of type int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on value of type int in /in/aX9PN on line 23 Comparing Ya and ... Warning: Trying to access array offset on value of type int in /in/aX9PN on line 25 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 29 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 33 -11650 VS Warning: Trying to access array offset on value of type int in /in/aX9PN on line 34 Ya wins! ---------- Warning: Trying to access array offset on value of type int in /in/aX9PN on line 47 ---------- Top: Orchid: 4 Ocean: 3 Ya: 2 Cala: 1 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 54 Warning: Trying to access array offset on value of type int in /in/aX9PN on line 54 : ---------- Finalists: Orchid Ocean
Output for rfc.property-hooks
1 - OceanComparing Cala and Ocean... 5000 VS 6150 Ocean wins! Warning: Undefined array key 4 in /in/aX9PN on line 39 ---------- 2 - OrchidComparing Cala and Orchid... 4600 VS 7200 Orchid wins! Warning: Undefined array key 4 in /in/aX9PN on line 39 ---------- 3 - YaComparing Cala and Ya... 6000 VS 6950 Ya wins! Warning: Undefined array key 4 in /in/aX9PN on line 39 ---------- Warning: Trying to access array offset on int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on int in /in/aX9PN on line 23 Comparing Cala and ... Warning: Trying to access array offset on int in /in/aX9PN on line 25 Warning: Trying to access array offset on int in /in/aX9PN on line 29 Warning: Trying to access array offset on int in /in/aX9PN on line 33 -12600 VS Warning: Trying to access array offset on int in /in/aX9PN on line 34 Cala wins! Warning: Undefined array key 4 in /in/aX9PN on line 36 ---------- 2 - OrchidComparing Ocean and Orchid... 5750 VS 7200 Orchid wins! ---------- 3 - YaComparing Ocean and Ya... 7150 VS 6950 Ocean wins! ---------- Warning: Trying to access array offset on int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on int in /in/aX9PN on line 23 Comparing Ocean and ... Warning: Trying to access array offset on int in /in/aX9PN on line 25 Warning: Trying to access array offset on int in /in/aX9PN on line 29 Warning: Trying to access array offset on int in /in/aX9PN on line 33 -11450 VS Warning: Trying to access array offset on int in /in/aX9PN on line 34 Ocean wins! ---------- 3 - YaComparing Orchid and Ya... 8600 VS 6950 Orchid wins! ---------- Warning: Trying to access array offset on int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on int in /in/aX9PN on line 23 Comparing Orchid and ... Warning: Trying to access array offset on int in /in/aX9PN on line 25 Warning: Trying to access array offset on int in /in/aX9PN on line 29 Warning: Trying to access array offset on int in /in/aX9PN on line 33 -10000 VS Warning: Trying to access array offset on int in /in/aX9PN on line 34 Orchid wins! ---------- Warning: Trying to access array offset on int in /in/aX9PN on line 22 4 - Warning: Trying to access array offset on int in /in/aX9PN on line 23 Comparing Ya and ... Warning: Trying to access array offset on int in /in/aX9PN on line 25 Warning: Trying to access array offset on int in /in/aX9PN on line 29 Warning: Trying to access array offset on int in /in/aX9PN on line 33 -11650 VS Warning: Trying to access array offset on int in /in/aX9PN on line 34 Ya wins! ---------- Warning: Trying to access array offset on int in /in/aX9PN on line 47 ---------- Top: Orchid: 4 Ocean: 3 Ya: 2 Cala: 1 Warning: Trying to access array offset on int in /in/aX9PN on line 54 Warning: Trying to access array offset on int in /in/aX9PN on line 54 : ---------- Finalists: Orchid Ocean

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:
48.87 ms | 408 KiB | 8 Q