3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<h2>Spiders</h2> <h2>Beetles</h2> <h3>External morphology</h3> <h4>Head</h4> <h4>Thorax</h4> <h4>Legs</h4> <h3>Anatomy and physiology</h3> <h2>Ants</h2>'; preg_match_all('/<h(\d)>([^<]+)/', $html, $matches); $cdepth = $matches[1][0] - 1; foreach ($matches[1] as $key => $depth) { if ($depth > $cdepth) { echo "\n" . str_repeat(' ', $cdepth * 4) . "<ol>\n"; } elseif ($depth < $cdepth) { echo "</li>\n" . str_repeat(' ', $depth * 4) . "</ol>\n" . str_repeat(' ', $depth * 4) . "</li>\n"; } else { echo "</li>\n"; } $cdepth = $depth; echo str_repeat(' ', $cdepth * 4) . "<li><a href=\"{$matches[2][$key]}\">{$matches[2][$key]}</a>"; } while ($cdepth-- >= $matches[1][0]) { echo "</li>\n" . str_repeat(' ', $cdepth * 4) . "</ol>\n"; }

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.5.10.0100.00818.97
8.5.00.0110.01420.44
8.4.160.0100.01423.86
8.4.150.0030.00014.05
8.4.140.0150.00717.79
8.4.130.0120.00717.90
8.4.120.0120.00822.18
8.4.110.0120.00818.93
8.4.100.0090.01218.86
8.4.90.0160.00420.75
8.4.80.0130.00520.66
8.4.70.0090.00620.89
8.4.60.0130.00820.63
8.4.50.0100.01018.67
8.4.40.0090.01119.84
8.4.30.0090.00018.52
8.4.20.0080.01220.44
8.4.10.0040.00418.17
8.3.280.0100.01018.63
8.3.270.0130.00916.51
8.3.260.0130.00816.86
8.3.250.0100.00918.86
8.3.240.0090.00916.82
8.3.230.0110.00816.65
8.3.220.0090.00819.07
8.3.210.0130.00716.66
8.3.200.0120.01116.91
8.3.190.0040.00519.09
8.3.180.0110.00819.10
8.3.170.0100.00617.17
8.3.160.0180.00016.70
8.3.150.0120.00616.97
8.3.140.0040.00416.95
8.3.130.0090.00918.57
8.3.120.0090.00016.81
8.3.110.0060.00316.75
8.3.100.0030.00616.87
8.3.90.0120.00316.60
8.3.80.0060.00319.36
8.3.70.0150.00316.75
8.3.60.0030.01317.13
8.3.50.0120.00923.84
8.3.40.0110.00718.92
8.3.30.0040.01118.92
8.3.20.0050.00321.08
8.3.10.0050.00223.67
8.3.00.0080.00023.61
8.2.290.0120.00716.74
8.2.280.0120.01018.61
8.2.270.0140.00716.78
8.2.260.0040.01417.47
8.2.250.0040.00416.65
8.2.240.0160.00317.23
8.2.230.0040.00420.94
8.2.220.0100.01024.06
8.2.210.0080.00026.77
8.2.200.0100.00018.88
8.2.190.0110.00718.57
8.2.180.0110.00716.75
8.2.170.0110.00822.96
8.2.160.0120.00320.47
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00426.16
8.2.110.0100.00022.12
8.2.100.0090.00318.16
8.2.90.0030.00618.15
8.2.80.0060.00318.93
8.2.70.0030.00517.93
8.2.60.0040.00418.09
8.2.50.0060.00318.10
8.2.40.0110.00020.60
8.2.30.0000.00818.24
8.2.20.0000.00718.29
8.2.10.0050.00319.38
8.2.00.0050.00219.42
8.1.330.0100.01016.46
8.1.320.0130.00718.27
8.1.310.0110.00718.39
8.1.300.0000.00917.91
8.1.290.0030.00918.88
8.1.280.0000.01525.92
8.1.270.0030.00622.13
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.07
8.1.230.0100.00320.98
8.1.220.0000.00817.74
8.1.210.0040.00418.85
8.1.200.0060.00317.48
8.1.190.0050.00517.23
8.1.180.0050.00318.10
8.1.170.0030.00618.55
8.1.160.0030.00518.95
8.1.150.0040.00418.97
8.1.140.0050.00220.86
8.1.130.0030.00320.32
8.1.120.0080.00317.54
8.1.110.0030.00517.53
8.1.100.0040.00417.66
8.1.90.0040.00417.52
8.1.80.0040.00417.59
8.1.70.0040.00417.65
8.1.60.0080.00017.65
8.1.50.0040.00417.67
8.1.40.0040.00417.61
8.1.30.0030.00617.73
8.1.20.0050.00317.74
8.1.10.0000.00917.73
8.1.00.0030.00617.69
8.0.300.0000.00720.27
8.0.290.0030.00616.88
8.0.280.0000.00718.40
8.0.270.0080.00018.30
8.0.260.0030.00320.04
8.0.250.0000.00717.20
8.0.240.0040.00417.15
8.0.230.0040.00417.12
8.0.220.0040.00417.18
8.0.210.0070.00417.11
8.0.200.0070.00017.17
8.0.190.0080.00017.22
8.0.180.0000.00817.20
8.0.170.0050.00317.16
8.0.160.0080.00017.06
8.0.150.0000.00716.95
8.0.140.0060.00317.14
8.0.130.0030.00313.58
8.0.120.0000.00717.13
8.0.110.0040.00417.12
8.0.100.0040.00417.13
8.0.90.0030.00617.08
8.0.80.0120.00917.07
8.0.70.0040.00417.12
8.0.60.0040.00417.02
8.0.50.0070.00017.07
8.0.30.0070.01017.34
8.0.20.0080.01217.35
8.0.10.0000.00717.15
8.0.00.0110.00716.88
7.4.330.0000.00516.74
7.4.320.0060.00016.92
7.4.300.0000.00616.59
7.4.290.0000.00816.64
7.4.280.0000.00816.82
7.4.270.0050.00316.83
7.4.260.0040.00416.75
7.4.250.0040.00416.71
7.4.240.0020.00516.78
7.4.230.0000.00716.95
7.4.220.0030.00416.70
7.4.210.0090.00716.87
7.4.200.0040.00416.77
7.4.130.0070.01516.72
7.4.120.0140.00416.60
7.4.110.0140.00316.74
7.4.100.0070.01016.86
7.4.90.0080.00816.74
7.4.80.0110.01119.39
7.4.70.0040.01516.66
7.4.60.0160.00616.80
7.4.50.0040.00816.52
7.4.40.0130.01016.87
7.4.10.0040.01916.57
7.4.00.0110.00816.61
7.3.330.0000.00716.55
7.3.320.0030.00313.22
7.3.310.0030.00416.57
7.3.300.0030.00316.52
7.3.290.0090.00716.53
7.3.280.0120.01216.37
7.3.260.0000.01916.58
7.3.240.0140.00516.77
7.3.230.0160.00316.53
7.3.210.0040.01416.51
7.3.200.0140.00316.51
7.3.190.0110.00716.51
7.3.180.0130.00316.65
7.3.170.0040.01416.51
7.3.160.0080.01116.68
7.3.130.0070.01116.64
7.3.120.0120.01016.38
7.3.110.0120.01116.18
7.3.100.0110.00816.52
7.3.90.0110.00616.39
7.3.80.0040.01316.31
7.3.70.0100.01016.37
7.3.60.0120.00616.49
7.3.50.0110.01116.46
7.3.40.0150.00316.52
7.3.30.0120.00616.44
7.3.20.0120.00616.62
7.3.10.0110.00716.48
7.3.00.0100.00716.45
7.2.330.0030.01416.92
7.2.320.0120.00616.91
7.2.310.0120.00716.75
7.2.300.0110.01316.69
7.2.290.0110.00616.77
7.2.260.0100.01116.71
7.2.250.0120.01016.49
7.2.240.0150.00416.78
7.2.230.0090.01416.90
7.2.220.0180.00016.61
7.2.210.0190.00316.74
7.2.200.0150.00916.79
7.2.190.0180.00316.77
7.2.180.0100.01016.70
7.2.170.0120.00616.56
7.2.160.0090.00916.76
7.2.150.0120.00716.66
7.2.140.0110.00716.88
7.2.130.0060.01216.79
7.2.120.0090.01316.62
7.2.110.0090.01316.59
7.2.100.0120.00816.69
7.2.90.0090.00916.90
7.2.80.0070.01416.63
7.2.70.0060.01316.65
7.2.60.0100.00716.85
7.2.50.0150.00416.74
7.2.40.0110.00716.82
7.2.30.0060.01316.61
7.2.20.0050.01316.42
7.2.10.0120.00616.89
7.2.00.0070.01016.72

preferences:
171.5 ms | 403 KiB | 5 Q