3v4l.org

run code in 300+ PHP versions simultaneously
<?php $teams = array('All-Stars', 'Vets', 'Lightning', 'Bolt'); // HOW MANY WEEKS $weeks = 3; // MAKE ENOUGH ARRAY ELEMENTS FOR THE DISTRIBUTION $array = array_merge($teams, $teams); // POPULATE THE MATCHES ARRAY $matches = array(); while ($weeks) { foreach ($teams as $ptr => $team) { // FIND THE INDEX INTO THE DISTRIBUTION ARRAY $linkt = $ptr + $weeks; // SELECT THE HOME AND AWAY TEAMS $home = $team; $away = $array[$linkt]; $matches[$team][$weeks] = array('home' => $home, 'away' => $away); } // NEXT WEEK $weeks--; } // SORT THE MATCHES SENSIBLY SO WEEK ONE COMES FIRST foreach ($matches as $team => $contests) { ksort($contests); $matches[$team] = $contests; } // ACTIVATE THIS TO SEE WHAT THE $matches ARRAY LOOKS LIKE // print_r($matches); // CREATE THE TABLE OF MATCHUPS $out = NULL; $out .= "<table>"; $out .= PHP_EOL; // CREATE THE HEADERS FOR EACH WEEK $weeknums = end($matches); $out .= "<tr>"; $out .= '<th> Team </th>'; $out .= '<th> v </th>'; $out .= "<th> Team </th>"; $out .= '</tr>'; $out .= PHP_EOL; // CREATE THE MATRIX OF MATCHUPS foreach ($matches as $team => $contests) { $out .= "<form class='form-horizontal' action='".$_SERVER['PHP_SELF']."'d method='post'><tr><td><input type='text' name='teamone' value='$team' readonly></td>"; $out .= "<td> <b>v</b></td>"; foreach ($contests as $week => $matchup) { // print_r($matchup); $out .= "<td> <input type='text' name='teamtwo' value='{$matchup["away"]}' readonly> </td>"; } $out .= "</tr>"; $out .= PHP_EOL; } $out .= "<input class='btn btn-primary' type='submit' name='submit'></form></table>"; $out .= PHP_EOL; foreach ($matches as $team => $contests) { foreach ($contests as $week => $matchup) { print_r($matchup); if(is_array($matchup)){ foreach($matchup as $key => $value){ $home = $matchup['home']; $away = $matchup['away']; echo "INSERT INTO tourn_fixtures(teamone, teamtwo) values ('$home', '$away')\n"; } } } } echo "</pre>"; //echo $out;

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)
8.3.70.0090.00918.43
8.3.60.0150.00418.43
8.3.50.0040.01116.46
8.3.40.0110.01119.00
8.3.30.0090.00618.93
8.3.20.0000.00820.78
8.3.10.0030.00521.92
8.3.00.0040.00421.89
8.2.190.0160.00616.93
8.2.180.0100.00718.34
8.2.170.0140.00018.89
8.2.160.0170.00321.96
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0070.00026.16
8.2.110.0100.00021.00
8.2.100.0090.00318.03
8.2.90.0050.00317.83
8.2.80.0030.00519.82
8.2.70.0000.00817.75
8.2.60.0030.00517.50
8.2.50.0050.00318.03
8.2.40.0000.00819.78
8.2.30.0000.00919.43
8.2.20.0020.00518.15
8.2.10.0000.00719.43
8.2.00.0080.00019.36
8.1.280.0070.00725.92
8.1.270.0000.00920.83
8.1.260.0030.00626.35
8.1.250.0000.00828.09
8.1.240.0060.00321.30
8.1.230.0080.00417.64
8.1.220.0000.00818.01
8.1.210.0030.00618.77
8.1.200.0060.00317.38
8.1.190.0040.00417.36
8.1.180.0000.00918.10
8.1.170.0040.00417.70
8.1.160.0040.00419.14
8.1.150.0040.00418.75
8.1.140.0070.00020.75
8.1.130.0000.00820.22
8.1.120.0040.00417.44
8.1.110.0040.00417.55
8.1.100.0050.00317.43
8.1.90.0040.00417.54
8.1.80.0000.00717.56
8.1.70.0020.00517.40
8.1.60.0030.00517.60
8.1.50.0040.00417.59
8.1.40.0030.00617.53
8.1.30.0000.00817.71
8.1.20.0000.01117.74
8.1.10.0080.00017.63
8.1.00.0030.00617.59
8.0.300.0040.00420.01
8.0.290.0040.00416.88
8.0.280.0040.00418.51
8.0.270.0070.00018.20
8.0.260.0000.00720.16
8.0.250.0030.00317.05
8.0.240.0090.00016.99
8.0.230.0000.00717.05
8.0.220.0000.00816.95
8.0.210.0030.00316.99
8.0.200.0060.00017.07
8.0.190.0070.00017.02
8.0.180.0030.00517.00
8.0.170.0080.00017.02
8.0.160.0000.00716.98
8.0.150.0040.00416.94
8.0.140.0040.00416.89
8.0.130.0030.00313.45
8.0.120.0040.00416.77
8.0.110.0040.00416.86
8.0.100.0000.00817.04
8.0.90.0060.00316.81
8.0.80.0090.00916.92
8.0.70.0040.00417.00
8.0.60.0000.00716.95
8.0.50.0040.00416.93
8.0.30.0090.01217.24
8.0.20.0070.01517.13
8.0.10.0000.00816.91
8.0.00.0060.01216.63
7.4.330.0000.00616.67
7.4.320.0000.00616.70
7.4.300.0040.00416.70
7.4.290.0030.00516.71
7.4.280.0000.00816.64
7.4.270.0030.00316.70
7.4.260.0040.00416.59
7.4.250.0040.00416.57
7.4.240.0020.00516.59
7.4.230.0030.00316.66
7.4.220.0040.00316.62
7.4.210.0100.00916.57
7.4.200.0040.00416.71
7.4.130.0070.01116.60
7.4.120.0130.00416.78
7.4.110.0090.00916.81
7.4.100.0170.00016.54
7.4.90.0100.00716.73
7.4.80.0070.01019.39
7.4.70.0070.01416.61
7.4.60.0080.00816.54
7.4.50.0030.01316.72
7.4.40.0030.01316.63
7.4.10.0140.00315.12
7.4.00.0100.00515.04
7.3.330.0030.00316.29
7.3.320.0030.00313.30
7.3.310.0030.00316.48
7.3.300.0030.00316.46
7.3.290.0060.01116.43
7.3.260.0100.00716.51
7.3.240.0050.01216.59
7.3.230.0190.00416.45
7.3.210.0120.00616.68
7.3.200.0060.01216.51
7.3.190.0130.00416.38
7.3.180.0090.00616.57
7.3.170.0080.00816.52
7.3.160.0060.00916.59
7.3.130.0100.01314.93
7.3.120.0220.00414.86
7.3.110.0080.01514.69
7.3.100.0150.00914.71
7.3.90.0190.00314.87
7.3.80.0090.01214.49
7.3.70.0080.01114.75
7.3.60.0140.01114.90
7.3.50.0160.00814.57
7.3.40.0180.00414.75
7.3.30.0160.00314.83
7.3.20.0100.01714.69
7.3.10.0130.00914.60
7.3.00.0040.01714.74
7.2.330.0100.00716.56
7.2.320.0090.01416.73
7.2.310.0130.00316.84
7.2.300.0110.01116.79
7.2.290.0140.01116.54
7.2.260.0140.01014.92
7.2.250.0100.01414.96
7.2.240.0190.00615.12
7.2.230.0150.01215.14
7.2.220.0080.01915.05
7.2.210.0160.00514.82
7.2.200.0120.00915.15
7.2.190.0150.00615.18
7.2.180.0150.01014.85
7.2.170.0090.01214.75
7.2.160.0050.01914.93
7.2.150.0130.00915.11
7.2.140.0140.00914.95
7.2.130.0120.00714.88
7.2.120.0080.01014.82
7.2.110.0090.01315.09
7.2.100.0120.01215.07
7.2.90.0130.01315.14
7.2.80.0140.00714.90
7.2.70.0210.00714.71
7.2.60.0120.01215.13
7.2.50.0100.01015.03
7.2.40.0110.00814.71
7.2.30.0090.01214.97
7.2.20.0060.01314.93
7.2.10.0150.00615.22
7.2.00.0090.00615.03

preferences:
20.68 ms | 401 KiB | 5 Q