3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Fetch data from BD // $options = $stmt->query("SELECT * FROM Options")->fetch_all(PDO::FETCH_ASSOC); $options = [ ['id' => 1, 'name' => 'admin', 'ref' => 0], ['id' => 2, 'name' => 'A', 'ref' => 1], ['id' => 3, 'name' => 'B', 'ref' => 2], ['id' => 4, 'name' => 'C', 'ref' => 1], ['id' => 5, 'name' => 'D', 'ref' => 2], ['id' => 6, 'name' => 'E', 'ref' => 3], ['id' => 7, 'name' => 'F', 'ref' => 3], ['id' => 8, 'name' => 'G', 'ref' => 2], ]; $nodes = array(); $roots = array(); // init nodes indexed by IDs foreach ($options as $option) { $option['subIds'] = array(); // init subIds $nodes[$option['id']] = $option; } // build a recursive structure (by reference) foreach ($options as $option) { if ($option['ref'] == 0) { $roots[] = $option['id']; // add a root } else { $nodes[$option['ref']]['subIds'][] = $option['id']; // add a subnode } } // build recursive HTML-List function getSubtreeHTMLList($subOptionIds, $nodes) { $result = '<ul>'; foreach ($subOptionIds as $optionsId) { $result .= '<li>'; $result .= $nodes[$optionsId]['name']; if (count($nodes[$optionsId]['subIds'] > 0)) { $result .= getSubtreeHTMLList($nodes[$optionsId]['subIds'], $nodes); } $result .= '</li>'; } $result .= '</ul>'; return $result; } echo getSubtreeHTMLList($roots, $nodes); ?>

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.4.140.0150.00617.55
8.4.130.0070.01318.81
8.4.120.0110.00924.00
8.4.110.0070.00318.91
8.4.100.0130.00720.59
8.4.90.0160.00718.68
8.4.80.0020.00618.16
8.4.70.0130.00717.93
8.4.60.0100.00618.60
8.4.50.0120.00817.89
8.4.40.0190.00019.25
8.4.30.0190.00017.80
8.4.20.0180.00318.01
8.4.10.0090.00019.56
8.3.270.0090.01016.90
8.3.260.0050.00316.63
8.3.250.0040.01219.08
8.3.240.0060.00416.93
8.3.230.0030.00716.57
8.3.220.0050.00319.23
8.3.210.0140.00516.64
8.3.200.0050.00416.45
8.3.190.0120.00716.95
8.3.180.0130.00518.56
8.3.170.0160.00316.97
8.3.160.0050.00318.68
8.3.150.0070.00017.23
8.3.140.0050.00318.79
8.3.130.0040.00416.66
8.3.120.0030.00620.48
8.3.110.0060.00320.94
8.3.100.0060.00616.67
8.3.90.0120.00626.77
8.3.80.0060.00316.63
8.3.70.0110.00416.63
8.3.60.0070.01116.75
8.3.50.0200.00722.01
8.3.40.0060.00918.75
8.3.30.0060.01018.97
8.3.20.0000.00820.04
8.3.10.0000.00823.60
8.3.00.0000.00922.57
8.2.290.0110.00820.24
8.2.280.0050.00418.44
8.2.270.0040.00417.51
8.2.260.0120.00618.95
8.2.250.0040.00418.57
8.2.240.0110.00417.44
8.2.230.0090.00022.58
8.2.220.0100.00024.06
8.2.210.0130.00726.77
8.2.200.0070.00318.38
8.2.190.0120.00916.58
8.2.180.0060.00918.29
8.2.170.0150.00022.96
8.2.160.0070.00722.12
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00422.22
8.2.120.0040.00426.35
8.2.110.0100.00022.24
8.2.100.0070.00717.84
8.2.90.0040.00417.91
8.2.80.0060.00317.97
8.2.70.0000.00817.63
8.2.60.0040.00418.05
8.2.50.0060.00318.10
8.2.40.0030.00820.23
8.2.30.0080.00019.31
8.2.20.0070.00017.70
8.2.10.0060.00318.01
8.2.00.0040.00417.69
8.1.330.0070.01122.02
8.1.320.0120.00616.13
8.1.310.0000.01016.58
8.1.300.0070.01117.95
8.1.290.0000.00930.84
8.1.280.0180.00725.92
8.1.270.0050.00323.91
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0060.00322.51
8.1.230.0090.00320.96
8.1.220.0060.00317.80
8.1.210.0030.00618.89
8.1.200.0050.00517.23
8.1.190.0030.00517.23
8.1.180.0030.00618.10
8.1.170.0030.00618.65
8.1.160.0040.00422.14
8.1.150.0040.00418.74
8.1.140.0080.00019.54
8.1.130.0000.00718.83
8.1.120.0030.00317.40
8.1.110.0040.00417.48
8.1.100.0050.00317.39
8.1.90.0000.00717.36
8.1.80.0040.00417.43
8.1.70.0000.00717.36
8.1.60.0000.00717.47
8.1.50.0080.00017.53
8.1.40.0050.00517.53
8.1.30.0030.00517.70
8.1.20.0040.00417.61
8.1.10.0000.00717.59
8.1.00.0000.00717.44
8.0.300.0040.00419.92
8.0.290.0040.00416.75
8.0.280.0040.00418.38
8.0.270.0030.00316.79
8.0.260.0000.00618.45
8.0.250.0000.00716.94
8.0.240.0000.00717.09
8.0.230.0030.00317.03
8.0.220.0020.00516.93
8.0.210.0040.00416.95
8.0.200.0060.00017.08
8.0.190.0040.00417.02
8.0.180.0070.00017.02
8.0.170.0080.00017.03
8.0.160.0000.00717.01
8.0.150.0000.00817.00
8.0.140.0040.00416.88
8.0.130.0000.00513.46
8.0.120.0040.00416.92
8.0.110.0070.00016.84
8.0.100.0070.00016.94
8.0.90.0000.00716.98
8.0.80.0080.00716.86
8.0.70.0030.00516.79
8.0.60.0050.00316.87
8.0.50.0060.00317.07
8.0.30.0120.00617.03
8.0.20.0090.01117.40
8.0.10.0040.00417.02
8.0.00.0130.00616.68
7.4.330.0020.00215.08
7.4.320.0030.00316.56
7.4.300.0000.00616.60
7.4.290.0070.00016.65
7.4.280.0030.00616.46
7.4.270.0030.00316.54
7.4.260.0000.00716.54
7.4.250.0030.00316.45
7.4.240.0050.00216.52
7.4.230.0040.00416.61
7.4.220.0060.01216.42
7.4.210.0090.01416.54
7.4.200.0030.00316.52
7.4.160.0090.00816.60
7.4.150.0190.00017.40
7.4.140.0160.00817.86
7.4.130.0120.00616.62
7.4.120.0090.01016.61
7.4.110.0080.01216.50
7.4.100.0060.01016.57
7.4.90.0210.00816.51
7.4.80.0030.01719.39
7.4.70.0130.00416.53
7.4.60.0160.00616.44
7.4.50.0040.01116.66
7.4.40.0050.01416.55
7.4.30.0030.01516.45
7.4.00.0140.00414.91
7.3.330.0040.00413.46
7.3.320.0000.00513.43
7.3.310.0030.00316.48
7.3.300.0000.00716.39
7.3.290.0070.00816.44
7.3.280.0100.00816.47
7.3.270.0120.00817.40
7.3.260.0120.00816.51
7.3.250.0090.00916.40
7.3.240.0110.00916.45
7.3.230.0140.00316.45
7.3.210.0100.00716.40
7.3.200.0140.00516.69
7.3.190.0070.01016.59
7.3.180.0100.00716.42
7.3.170.0070.01116.54
7.3.160.0060.01216.49
7.2.330.0130.00716.79
7.2.320.0120.00616.58
7.2.310.0150.00416.78
7.2.300.0090.00616.46
7.2.290.0120.00616.88
7.2.60.0000.01616.53
7.2.00.0040.00819.53
7.1.200.0100.00315.62
7.1.100.0210.00318.02
7.1.70.0030.00617.04
7.1.60.0070.00517.30
7.1.50.0100.01316.64
7.1.00.0070.07022.30
7.0.200.0160.00314.82
7.0.100.1370.07020.09
7.0.90.0730.07719.98
7.0.80.2400.07720.20
7.0.70.0170.05319.98
7.0.60.0230.07320.01
7.0.50.0430.04320.27
7.0.40.0100.06720.35
7.0.30.0900.09020.25
7.0.20.0330.05320.38
7.0.10.0270.05320.32
7.0.00.3130.06720.39
5.6.250.0170.05320.55
5.6.240.0030.07320.64
5.6.230.0830.06720.51
5.6.220.0100.08320.64
5.6.210.0170.08020.76
5.6.200.0230.07321.21
5.6.190.0200.05321.10
5.6.180.0270.05321.03
5.6.170.0200.06721.11
5.6.160.0200.05321.15
5.6.150.0000.08021.11
5.6.140.0170.08021.11
5.6.130.0130.06721.04
5.6.120.0270.07321.04
5.6.110.0170.05721.18
5.6.100.0230.07021.13
5.6.90.0170.08321.05
5.6.80.0200.07320.57
5.6.70.0200.04720.53
5.6.60.0170.05020.47
5.6.50.0070.08720.52
5.6.40.0070.06320.39
5.6.30.0200.06720.40
5.6.20.0170.05320.47
5.6.10.0170.05020.47
5.6.00.0130.05020.45

preferences:
34.41 ms | 403 KiB | 5 Q