3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['Tibki', 3, 8.0, 6719], ['Nordest', 3, 8.1, 8954], ['Spasio', 3, 8.1, 9362], ['Hasienda', 4, 9.0, 10211], ['The fern', 3, 8.9, 11687], ['Belesa', 4, 8.1, 13234], ['Resort', 3, 9.1, 14252], ['El Hotel', 3, 8.2, 14577], ['Fortuna', 4, 8.1, 15237], ['Mikinos', 3, 8.0, 16289], ['Presa', 4, 8.5, 20360], ['Ramada', 5, 8.1, 23676], ['Olila', 5, 8.6, 27166], ['Goa', 5, 8.2, 33129], ['Vivanta', 5, 8.4, 36816], ['The lila', 5, 9.0, 37579], ['Grand', 5, 8.4, 40720], ]; $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 Tibki and Nordest... 8719 VS 8954 Tibki wins! ---------- Comparing Tibki and Spasio... 8719 VS 9362 Tibki wins! ---------- Comparing Tibki and Hasienda... 30719 VS 10211 Hasienda wins! ---------- Comparing Tibki and The fern... 24719 VS 11687 The fern wins! ---------- Comparing Tibki and Belesa... 12719 VS 13234 Tibki wins! ---------- Comparing Tibki and Resort... 28719 VS 14252 Resort wins! ---------- Comparing Tibki and El Hotel... 10719 VS 14577 Tibki wins! ---------- Comparing Tibki and Fortuna... 12719 VS 15237 Tibki wins! ---------- Comparing Tibki and Mikinos... 6719 VS 16289 Tibki wins! ---------- Comparing Tibki and Presa... 20719 VS 20360 Presa wins! ---------- Comparing Tibki and Ramada... 16719 VS 23676 Tibki wins! ---------- Comparing Tibki and Olila... 26719 VS 27166 Tibki wins! ---------- Comparing Tibki and Goa... 18719 VS 33129 Tibki wins! ---------- Comparing Tibki and Vivanta... 22719 VS 36816 Tibki wins! ---------- Comparing Tibki and The lila... 34719 VS 37579 Tibki wins! ---------- Comparing Tibki and Grand... 22719 VS 40720 Tibki wins! ---------- Comparing Nordest and Spasio... 8954 VS 9362 Nordest wins! ---------- Comparing Nordest and Hasienda... 30954 VS 10211 Hasienda wins! ---------- Comparing Nordest and The fern... 24954 VS 11687 The fern wins! ---------- Comparing Nordest and Belesa... 12954 VS 13234 Nordest wins! ---------- Comparing Nordest and Resort... 28954 VS 14252 Resort wins! ---------- Comparing Nordest and El Hotel... 10954 VS 14577 Nordest wins! ---------- Comparing Nordest and Fortuna... 12954 VS 15237 Nordest wins! ---------- Comparing Nordest and Mikinos... 6954 VS 16289 Nordest wins! ---------- Comparing Nordest and Presa... 20954 VS 20360 Presa wins! ---------- Comparing Nordest and Ramada... 16954 VS 23676 Nordest wins! ---------- Comparing Nordest and Olila... 26954 VS 27166 Nordest wins! ---------- Comparing Nordest and Goa... 18954 VS 33129 Nordest wins! ---------- Comparing Nordest and Vivanta... 22954 VS 36816 Nordest wins! ---------- Comparing Nordest and The lila... 34954 VS 37579 Nordest wins! ---------- Comparing Nordest and Grand... 22954 VS 40720 Nordest wins! ---------- Comparing Spasio and Hasienda... 31362 VS 10211 Hasienda wins! ---------- Comparing Spasio and The fern... 25362 VS 11687 The fern wins! ---------- Comparing Spasio and Belesa... 13362 VS 13234 Belesa wins! ---------- Comparing Spasio and Resort... 29362 VS 14252 Resort wins! ---------- Comparing Spasio and El Hotel... 11362 VS 14577 Spasio wins! ---------- Comparing Spasio and Fortuna... 13362 VS 15237 Spasio wins! ---------- Comparing Spasio and Mikinos... 7362 VS 16289 Spasio wins! ---------- Comparing Spasio and Presa... 21362 VS 20360 Presa wins! ---------- Comparing Spasio and Ramada... 17362 VS 23676 Spasio wins! ---------- Comparing Spasio and Olila... 27362 VS 27166 Olila wins! ---------- Comparing Spasio and Goa... 19362 VS 33129 Spasio wins! ---------- Comparing Spasio and Vivanta... 23362 VS 36816 Spasio wins! ---------- Comparing Spasio and The lila... 35362 VS 37579 Spasio wins! ---------- Comparing Spasio and Grand... 23362 VS 40720 Spasio wins! ---------- Comparing Hasienda and The fern... 4211 VS 11687 Hasienda wins! ---------- Comparing Hasienda and Belesa... -7789 VS 13234 Hasienda wins! ---------- Comparing Hasienda and Resort... 8211 VS 14252 Hasienda wins! ---------- Comparing Hasienda and El Hotel... -9789 VS 14577 Hasienda wins! ---------- Comparing Hasienda and Fortuna... -7789 VS 15237 Hasienda wins! ---------- Comparing Hasienda and Mikinos... -13789 VS 16289 Hasienda wins! ---------- Comparing Hasienda and Presa... 211 VS 20360 Hasienda wins! ---------- Comparing Hasienda and Ramada... -3789 VS 23676 Hasienda wins! ---------- Comparing Hasienda and Olila... 6211 VS 27166 Hasienda wins! ---------- Comparing Hasienda and Goa... -1789 VS 33129 Hasienda wins! ---------- Comparing Hasienda and Vivanta... 2211 VS 36816 Hasienda wins! ---------- Comparing Hasienda and The lila... 14211 VS 37579 Hasienda wins! ---------- Comparing Hasienda and Grand... 2211 VS 40720 Hasienda wins! ---------- Comparing The fern and Belesa... -313 VS 13234 The fern wins! ---------- Comparing The fern and Resort... 15687 VS 14252 Resort wins! ---------- Comparing The fern and El Hotel... -2313 VS 14577 The fern wins! ---------- Comparing The fern and Fortuna... -313 VS 15237 The fern wins! ---------- Comparing The fern and Mikinos... -6313 VS 16289 The fern wins! ---------- Comparing The fern and Presa... 7687 VS 20360 The fern wins! ---------- Comparing The fern and Ramada... 3687 VS 23676 The fern wins! ---------- Comparing The fern and Olila... 13687 VS 27166 The fern wins! ---------- Comparing The fern and Goa... 5687 VS 33129 The fern wins! ---------- Comparing The fern and Vivanta... 9687 VS 36816 The fern wins! ---------- Comparing The fern and The lila... 21687 VS 37579 The fern wins! ---------- Comparing The fern and Grand... 9687 VS 40720 The fern wins! ---------- Comparing Belesa and Resort... 29234 VS 14252 Resort wins! ---------- Comparing Belesa and El Hotel... 11234 VS 14577 Belesa wins! ---------- Comparing Belesa and Fortuna... 13234 VS 15237 Belesa wins! ---------- Comparing Belesa and Mikinos... 7234 VS 16289 Belesa wins! ---------- Comparing Belesa and Presa... 21234 VS 20360 Presa wins! ---------- Comparing Belesa and Ramada... 17234 VS 23676 Belesa wins! ---------- Comparing Belesa and Olila... 27234 VS 27166 Olila wins! ---------- Comparing Belesa and Goa... 19234 VS 33129 Belesa wins! ---------- Comparing Belesa and Vivanta... 23234 VS 36816 Belesa wins! ---------- Comparing Belesa and The lila... 35234 VS 37579 Belesa wins! ---------- Comparing Belesa and Grand... 23234 VS 40720 Belesa wins! ---------- Comparing Resort and El Hotel... -3748 VS 14577 Resort wins! ---------- Comparing Resort and Fortuna... -1748 VS 15237 Resort wins! ---------- Comparing Resort and Mikinos... -7748 VS 16289 Resort wins! ---------- Comparing Resort and Presa... 6252 VS 20360 Resort wins! ---------- Comparing Resort and Ramada... 2252 VS 23676 Resort wins! ---------- Comparing Resort and Olila... 12252 VS 27166 Resort wins! ---------- Comparing Resort and Goa... 4252 VS 33129 Resort wins! ---------- Comparing Resort and Vivanta... 8252 VS 36816 Resort wins! ---------- Comparing Resort and The lila... 20252 VS 37579 Resort wins! ---------- Comparing Resort and Grand... 8252 VS 40720 Resort wins! ---------- Comparing El Hotel and Fortuna... 16577 VS 15237 Fortuna wins! ---------- Comparing El Hotel and Mikinos... 10577 VS 16289 El Hotel wins! ---------- Comparing El Hotel and Presa... 24577 VS 20360 Presa wins! ---------- Comparing El Hotel and Ramada... 20577 VS 23676 El Hotel wins! ---------- Comparing El Hotel and Olila... 30577 VS 27166 Olila wins! ---------- Comparing El Hotel and Goa... 22577 VS 33129 El Hotel wins! ---------- Comparing El Hotel and Vivanta... 26577 VS 36816 El Hotel wins! ---------- Comparing El Hotel and The lila... 38577 VS 37579 The lila wins! ---------- Comparing El Hotel and Grand... 26577 VS 40720 El Hotel wins! ---------- Comparing Fortuna and Mikinos... 9237 VS 16289 Fortuna wins! ---------- Comparing Fortuna and Presa... 23237 VS 20360 Presa wins! ---------- Comparing Fortuna and Ramada... 19237 VS 23676 Fortuna wins! ---------- Comparing Fortuna and Olila... 29237 VS 27166 Olila wins! ---------- Comparing Fortuna and Goa... 21237 VS 33129 Fortuna wins! ---------- Comparing Fortuna and Vivanta... 25237 VS 36816 Fortuna wins! ---------- Comparing Fortuna and The lila... 37237 VS 37579 Fortuna wins! ---------- Comparing Fortuna and Grand... 25237 VS 40720 Fortuna wins! ---------- Comparing Mikinos and Presa... 30289 VS 20360 Presa wins! ---------- Comparing Mikinos and Ramada... 26289 VS 23676 Ramada wins! ---------- Comparing Mikinos and Olila... 36289 VS 27166 Olila wins! ---------- Comparing Mikinos and Goa... 28289 VS 33129 Mikinos wins! ---------- Comparing Mikinos and Vivanta... 32289 VS 36816 Mikinos wins! ---------- Comparing Mikinos and The lila... 44289 VS 37579 The lila wins! ---------- Comparing Mikinos and Grand... 32289 VS 40720 Mikinos wins! ---------- Comparing Presa and Ramada... 16360 VS 23676 Presa wins! ---------- Comparing Presa and Olila... 26360 VS 27166 Presa wins! ---------- Comparing Presa and Goa... 18360 VS 33129 Presa wins! ---------- Comparing Presa and Vivanta... 22360 VS 36816 Presa wins! ---------- Comparing Presa and The lila... 34360 VS 37579 Presa wins! ---------- Comparing Presa and Grand... 22360 VS 40720 Presa wins! ---------- Comparing Ramada and Olila... 33676 VS 27166 Olila wins! ---------- Comparing Ramada and Goa... 25676 VS 33129 Ramada wins! ---------- Comparing Ramada and Vivanta... 29676 VS 36816 Ramada wins! ---------- Comparing Ramada and The lila... 41676 VS 37579 The lila wins! ---------- Comparing Ramada and Grand... 29676 VS 40720 Ramada wins! ---------- Comparing Olila and Goa... 19166 VS 33129 Olila wins! ---------- Comparing Olila and Vivanta... 23166 VS 36816 Olila wins! ---------- Comparing Olila and The lila... 35166 VS 37579 Olila wins! ---------- Comparing Olila and Grand... 23166 VS 40720 Olila wins! ---------- Comparing Goa and Vivanta... 37129 VS 36816 Vivanta wins! ---------- Comparing Goa and The lila... 49129 VS 37579 The lila wins! ---------- Comparing Goa and Grand... 37129 VS 40720 Goa wins! ---------- Comparing Vivanta and The lila... 48816 VS 37579 The lila wins! ---------- Comparing Vivanta and Grand... 36816 VS 40720 Vivanta wins! ---------- Comparing The lila and Grand... 25579 VS 40720 The lila wins! ---------- ---------- Top: Hasienda: 16 Resort: 15 The fern: 14 Presa: 13 Tibki: 12 Nordest: 11 Olila: 10 Belesa: 9 Spasio: 8 Fortuna: 7 The lila: 6 El Hotel: 5 Ramada: 4 Mikinos: 3 Vivanta: 2 Goa: 1 Grand: 0 ---------- Finalists: Hasienda Resort
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/hqdVZ 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/hqdVZ on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/hqdVZ on line 3
Process exited with code 255.