3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $hotels = [ ['Issara Resort', 3, 8.2, 4550], ['Cata', 3, 8.7, 5921], ['Sun', 3, 8.6, 5970], ['Ocean', 3, 8.2, 6371], ['Orchid', 3, 8.0, 6745], ['Ya', 3, 8.7, 6745], ['Phuket', 3, 8.2, 7420], ['Baa', 3, 8.0, 8544], ['The', 3, 8.4, 8994], ['Bamboo', 3, 8.5, 8994], ['Cata', 4, 8.0, 9376], ['Shugar', 3, 8.1, 9443], ['Phuket B', 3, 8.7, 10493], ['Villa', 3, 8.7, 11242], ['Centara', 4, 8.2, 11247], ['The old', 4, 8.2, 11992], ['Cantari', 4, 8.6, 11992], ['By', 3, 8.4, 11992], ['Shugar m', 3, 8.5, 12141], ['Panwa', 4, 8.1, 12179], ]; $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.22, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Comparing Issara Resort and Cata... 14550 VS 5921 Cata wins! ---------- Comparing Issara Resort and Sun... 12550 VS 5970 Sun wins! ---------- Comparing Issara Resort and Ocean... 4550 VS 6371 Issara Resort wins! ---------- Comparing Issara Resort and Orchid... 550 VS 6745 Issara Resort wins! ---------- Comparing Issara Resort and Ya... 14550 VS 6745 Ya wins! ---------- Comparing Issara Resort and Phuket... 4550 VS 7420 Issara Resort wins! ---------- Comparing Issara Resort and Baa... 550 VS 8544 Issara Resort wins! ---------- Comparing Issara Resort and The... 8550 VS 8994 Issara Resort wins! ---------- Comparing Issara Resort and Bamboo... 10550 VS 8994 Bamboo wins! ---------- Comparing Issara Resort and Cata... 4550 VS 9376 Issara Resort wins! ---------- Comparing Issara Resort and Shugar... 2550 VS 9443 Issara Resort wins! ---------- Comparing Issara Resort and Phuket B... 14550 VS 10493 Phuket B wins! ---------- Comparing Issara Resort and Villa... 14550 VS 11242 Villa wins! ---------- Comparing Issara Resort and Centara... 8550 VS 11247 Issara Resort wins! ---------- Comparing Issara Resort and The old... 8550 VS 11992 Issara Resort wins! ---------- Comparing Issara Resort and Cantari... 16550 VS 11992 Cantari wins! ---------- Comparing Issara Resort and By... 8550 VS 11992 Issara Resort wins! ---------- Comparing Issara Resort and Shugar m... 10550 VS 12141 Issara Resort wins! ---------- Comparing Issara Resort and Panwa... 6550 VS 12179 Issara Resort wins! ---------- Comparing Cata and Sun... 3921 VS 5970 Cata wins! ---------- Comparing Cata and Ocean... -4079 VS 6371 Cata wins! ---------- Comparing Cata and Orchid... -8079 VS 6745 Cata wins! ---------- Comparing Cata and Ya... 5921 VS 6745 Cata wins! ---------- Comparing Cata and Phuket... -4079 VS 7420 Cata wins! ---------- Comparing Cata and Baa... -8079 VS 8544 Cata wins! ---------- Comparing Cata and The... -79 VS 8994 Cata wins! ---------- Comparing Cata and Bamboo... 1921 VS 8994 Cata wins! ---------- Comparing Cata and Cata... -4079 VS 9376 Cata wins! ---------- Comparing Cata and Shugar... -6079 VS 9443 Cata wins! ---------- Comparing Cata and Phuket B... 5921 VS 10493 Cata wins! ---------- Comparing Cata and Villa... 5921 VS 11242 Cata wins! ---------- Comparing Cata and Centara... -79 VS 11247 Cata wins! ---------- Comparing Cata and The old... -79 VS 11992 Cata wins! ---------- Comparing Cata and Cantari... 7921 VS 11992 Cata wins! ---------- Comparing Cata and By... -79 VS 11992 Cata wins! ---------- Comparing Cata and Shugar m... 1921 VS 12141 Cata wins! ---------- Comparing Cata and Panwa... -2079 VS 12179 Cata wins! ---------- Comparing Sun and Ocean... -2030 VS 6371 Sun wins! ---------- Comparing Sun and Orchid... -6030 VS 6745 Sun wins! ---------- Comparing Sun and Ya... 7970 VS 6745 Ya wins! ---------- Comparing Sun and Phuket... -2030 VS 7420 Sun wins! ---------- Comparing Sun and Baa... -6030 VS 8544 Sun wins! ---------- Comparing Sun and The... 1970 VS 8994 Sun wins! ---------- Comparing Sun and Bamboo... 3970 VS 8994 Sun wins! ---------- Comparing Sun and Cata... -2030 VS 9376 Sun wins! ---------- Comparing Sun and Shugar... -4030 VS 9443 Sun wins! ---------- Comparing Sun and Phuket B... 7970 VS 10493 Sun wins! ---------- Comparing Sun and Villa... 7970 VS 11242 Sun wins! ---------- Comparing Sun and Centara... 1970 VS 11247 Sun wins! ---------- Comparing Sun and The old... 1970 VS 11992 Sun wins! ---------- Comparing Sun and Cantari... 9970 VS 11992 Sun wins! ---------- Comparing Sun and By... 1970 VS 11992 Sun wins! ---------- Comparing Sun and Shugar m... 3970 VS 12141 Sun wins! ---------- Comparing Sun and Panwa... -30 VS 12179 Sun wins! ---------- Comparing Ocean and Orchid... 2371 VS 6745 Ocean wins! ---------- Comparing Ocean and Ya... 16371 VS 6745 Ya wins! ---------- Comparing Ocean and Phuket... 6371 VS 7420 Ocean wins! ---------- Comparing Ocean and Baa... 2371 VS 8544 Ocean wins! ---------- Comparing Ocean and The... 10371 VS 8994 The wins! ---------- Comparing Ocean and Bamboo... 12371 VS 8994 Bamboo wins! ---------- Comparing Ocean and Cata... 6371 VS 9376 Ocean wins! ---------- Comparing Ocean and Shugar... 4371 VS 9443 Ocean wins! ---------- Comparing Ocean and Phuket B... 16371 VS 10493 Phuket B wins! ---------- Comparing Ocean and Villa... 16371 VS 11242 Villa wins! ---------- Comparing Ocean and Centara... 10371 VS 11247 Ocean wins! ---------- Comparing Ocean and The old... 10371 VS 11992 Ocean wins! ---------- Comparing Ocean and Cantari... 18371 VS 11992 Cantari wins! ---------- Comparing Ocean and By... 10371 VS 11992 Ocean wins! ---------- Comparing Ocean and Shugar m... 12371 VS 12141 Shugar m wins! ---------- Comparing Ocean and Panwa... 8371 VS 12179 Ocean wins! ---------- Comparing Orchid and Ya... 20745 VS 6745 Ya wins! ---------- Comparing Orchid and Phuket... 10745 VS 7420 Phuket wins! ---------- Comparing Orchid and Baa... 6745 VS 8544 Orchid wins! ---------- Comparing Orchid and The... 14745 VS 8994 The wins! ---------- Comparing Orchid and Bamboo... 16745 VS 8994 Bamboo wins! ---------- Comparing Orchid and Cata... 10745 VS 9376 Cata wins! ---------- Comparing Orchid and Shugar... 8745 VS 9443 Orchid wins! ---------- Comparing Orchid and Phuket B... 20745 VS 10493 Phuket B wins! ---------- Comparing Orchid and Villa... 20745 VS 11242 Villa wins! ---------- Comparing Orchid and Centara... 14745 VS 11247 Centara wins! ---------- Comparing Orchid and The old... 14745 VS 11992 The old wins! ---------- Comparing Orchid and Cantari... 22745 VS 11992 Cantari wins! ---------- Comparing Orchid and By... 14745 VS 11992 By wins! ---------- Comparing Orchid and Shugar m... 16745 VS 12141 Shugar m wins! ---------- Comparing Orchid and Panwa... 12745 VS 12179 Panwa wins! ---------- Comparing Ya and Phuket... -3255 VS 7420 Ya wins! ---------- Comparing Ya and Baa... -7255 VS 8544 Ya wins! ---------- Comparing Ya and The... 745 VS 8994 Ya wins! ---------- Comparing Ya and Bamboo... 2745 VS 8994 Ya wins! ---------- Comparing Ya and Cata... -3255 VS 9376 Ya wins! ---------- Comparing Ya and Shugar... -5255 VS 9443 Ya wins! ---------- Comparing Ya and Phuket B... 6745 VS 10493 Ya wins! ---------- Comparing Ya and Villa... 6745 VS 11242 Ya wins! ---------- Comparing Ya and Centara... 745 VS 11247 Ya wins! ---------- Comparing Ya and The old... 745 VS 11992 Ya wins! ---------- Comparing Ya and Cantari... 8745 VS 11992 Ya wins! ---------- Comparing Ya and By... 745 VS 11992 Ya wins! ---------- Comparing Ya and Shugar m... 2745 VS 12141 Ya wins! ---------- Comparing Ya and Panwa... -1255 VS 12179 Ya wins! ---------- Comparing Phuket and Baa... 3420 VS 8544 Phuket wins! ---------- Comparing Phuket and The... 11420 VS 8994 The wins! ---------- Comparing Phuket and Bamboo... 13420 VS 8994 Bamboo wins! ---------- Comparing Phuket and Cata... 7420 VS 9376 Phuket wins! ---------- Comparing Phuket and Shugar... 5420 VS 9443 Phuket wins! ---------- Comparing Phuket and Phuket B... 17420 VS 10493 Phuket B wins! ---------- Comparing Phuket and Villa... 17420 VS 11242 Villa wins! ---------- Comparing Phuket and Centara... 11420 VS 11247 Centara wins! ---------- Comparing Phuket and The old... 11420 VS 11992 Phuket wins! ---------- Comparing Phuket and Cantari... 19420 VS 11992 Cantari wins! ---------- Comparing Phuket and By... 11420 VS 11992 Phuket wins! ---------- Comparing Phuket and Shugar m... 13420 VS 12141 Shugar m wins! ---------- Comparing Phuket and Panwa... 9420 VS 12179 Phuket wins! ---------- Comparing Baa and The... 16544 VS 8994 The wins! ---------- Comparing Baa and Bamboo... 18544 VS 8994 Bamboo wins! ---------- Comparing Baa and Cata... 12544 VS 9376 Cata wins! ---------- Comparing Baa and Shugar... 10544 VS 9443 Shugar wins! ---------- Comparing Baa and Phuket B... 22544 VS 10493 Phuket B wins! ---------- Comparing Baa and Villa... 22544 VS 11242 Villa wins! ---------- Comparing Baa and Centara... 16544 VS 11247 Centara wins! ---------- Comparing Baa and The old... 16544 VS 11992 The old wins! ---------- Comparing Baa and Cantari... 24544 VS 11992 Cantari wins! ---------- Comparing Baa and By... 16544 VS 11992 By wins! ---------- Comparing Baa and Shugar m... 18544 VS 12141 Shugar m wins! ---------- Comparing Baa and Panwa... 14544 VS 12179 Panwa wins! ---------- Comparing The and Bamboo... 10994 VS 8994 Bamboo wins! ---------- Comparing The and Cata... 4994 VS 9376 The wins! ---------- Comparing The and Shugar... 2994 VS 9443 The wins! ---------- Comparing The and Phuket B... 14994 VS 10493 Phuket B wins! ---------- Comparing The and Villa... 14994 VS 11242 Villa wins! ---------- Comparing The and Centara... 8994 VS 11247 The wins! ---------- Comparing The and The old... 8994 VS 11992 The wins! ---------- Comparing The and Cantari... 16994 VS 11992 Cantari wins! ---------- Comparing The and By... 8994 VS 11992 The wins! ---------- Comparing The and Shugar m... 10994 VS 12141 The wins! ---------- Comparing The and Panwa... 6994 VS 12179 The wins! ---------- Comparing Bamboo and Cata... 2994 VS 9376 Bamboo wins! ---------- Comparing Bamboo and Shugar... 994 VS 9443 Bamboo wins! ---------- Comparing Bamboo and Phuket B... 12994 VS 10493 Phuket B wins! ---------- Comparing Bamboo and Villa... 12994 VS 11242 Villa wins! ---------- Comparing Bamboo and Centara... 6994 VS 11247 Bamboo wins! ---------- Comparing Bamboo and The old... 6994 VS 11992 Bamboo wins! ---------- Comparing Bamboo and Cantari... 14994 VS 11992 Cantari wins! ---------- Comparing Bamboo and By... 6994 VS 11992 Bamboo wins! ---------- Comparing Bamboo and Shugar m... 8994 VS 12141 Bamboo wins! ---------- Comparing Bamboo and Panwa... 4994 VS 12179 Bamboo wins! ---------- Comparing Cata and Shugar... 7376 VS 9443 Cata wins! ---------- Comparing Cata and Phuket B... 19376 VS 10493 Phuket B wins! ---------- Comparing Cata and Villa... 19376 VS 11242 Villa wins! ---------- Comparing Cata and Centara... 13376 VS 11247 Centara wins! ---------- Comparing Cata and The old... 13376 VS 11992 The old wins! ---------- Comparing Cata and Cantari... 21376 VS 11992 Cantari wins! ---------- Comparing Cata and By... 13376 VS 11992 By wins! ---------- Comparing Cata and Shugar m... 15376 VS 12141 Shugar m wins! ---------- Comparing Cata and Panwa... 11376 VS 12179 Cata wins! ---------- Comparing Shugar and Phuket B... 21443 VS 10493 Phuket B wins! ---------- Comparing Shugar and Villa... 21443 VS 11242 Villa wins! ---------- Comparing Shugar and Centara... 15443 VS 11247 Centara wins! ---------- Comparing Shugar and The old... 15443 VS 11992 The old wins! ---------- Comparing Shugar and Cantari... 23443 VS 11992 Cantari wins! ---------- Comparing Shugar and By... 15443 VS 11992 By wins! ---------- Comparing Shugar and Shugar m... 17443 VS 12141 Shugar m wins! ---------- Comparing Shugar and Panwa... 13443 VS 12179 Panwa wins! ---------- Comparing Phuket B and Villa... 10493 VS 11242 Phuket B wins! ---------- Comparing Phuket B and Centara... 4493 VS 11247 Phuket B wins! ---------- Comparing Phuket B and The old... 4493 VS 11992 Phuket B wins! ---------- Comparing Phuket B and Cantari... 12493 VS 11992 Cantari wins! ---------- Comparing Phuket B and By... 4493 VS 11992 Phuket B wins! ---------- Comparing Phuket B and Shugar m... 6493 VS 12141 Phuket B wins! ---------- Comparing Phuket B and Panwa... 2493 VS 12179 Phuket B wins! ---------- Comparing Villa and Centara... 5242 VS 11247 Villa wins! ---------- Comparing Villa and The old... 5242 VS 11992 Villa wins! ---------- Comparing Villa and Cantari... 13242 VS 11992 Cantari wins! ---------- Comparing Villa and By... 5242 VS 11992 Villa wins! ---------- Comparing Villa and Shugar m... 7242 VS 12141 Villa wins! ---------- Comparing Villa and Panwa... 3242 VS 12179 Villa wins! ---------- Comparing Centara and The old... 11247 VS 11992 Centara wins! ---------- Comparing Centara and Cantari... 19247 VS 11992 Cantari wins! ---------- Comparing Centara and By... 11247 VS 11992 Centara wins! ---------- Comparing Centara and Shugar m... 13247 VS 12141 Shugar m wins! ---------- Comparing Centara and Panwa... 9247 VS 12179 Centara wins! ---------- Comparing The old and Cantari... 19992 VS 11992 Cantari wins! ---------- Comparing The old and By... 11992 VS 11992 By wins! ---------- Comparing The old and Shugar m... 13992 VS 12141 Shugar m wins! ---------- Comparing The old and Panwa... 9992 VS 12179 The old wins! ---------- Comparing Cantari and By... 3992 VS 11992 Cantari wins! ---------- Comparing Cantari and Shugar m... 5992 VS 12141 Cantari wins! ---------- Comparing Cantari and Panwa... 1992 VS 12179 Cantari wins! ---------- Comparing By and Shugar m... 13992 VS 12141 Shugar m wins! ---------- Comparing By and Panwa... 9992 VS 12179 By wins! ---------- Comparing Shugar m and Panwa... 8141 VS 12179 Shugar m wins! ---------- ---------- Top: Cata: 19 Ya: 18 Sun: 17 Cantari: 16 Phuket B: 15 Villa: 14 Bamboo: 13 Issara Resort: 12 The: 11 Shugar m: 10 Ocean: 9 Centara: 8 Phuket: 7 By: 6 The old: 5 Cata: 4 Panwa: 3 Orchid: 2 Shugar: 1 Baa: 0 ---------- Finalists: Cata Ya
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/u965r 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/u965r on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/u965r on line 3
Process exited with code 255.