3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isLi($line) { return strstr($line, '<li'); } $text = 'Some text <strong>Some other text</strong> <li>Element A1</li><li>Element A2</li> <li>Element A3</li> Text that separates group A from group B <li>Element B1</li> <li>Element B2</li> <li>Element B3</li> <li>Element B4</li> <strong>Element that separates group B from group C</strong> <li>Element C1</li> <li>Element C2</li> Text can follow. <li>Hello, nothing follows this</li>'; $array = explode("\n", $text); $html = ''; $previousWasLi = false; foreach ($array as $line) { if (empty($line)) { continue; } if (isLi($line) && $previousWasLi == false) { $html .= "<ul>\n"; $html .= $line ."\n"; $previousWasLi = true; } elseif (isLi($line) && $previousWasLi == true) { $html .= $line ."\n"; $previousWasLi = true; } elseif (!isLi($line) && $previousWasLi == true) { $html .= "</ul>\n"; $html .= $line ."\n"; $previousWasLi = false; } elseif (!isLi($line) && $previousWasLi == false) { $html .= $line ."\n"; } } // if the last line was an li, we need to close the ul if ($previousWasLi) { $html .= '</ul>'; } echo $html;

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.60.0150.00018.46
8.3.50.0080.00818.29
8.3.40.0060.00918.78
8.3.30.0100.00718.71
8.3.20.0000.00818.98
8.3.10.0040.00420.97
8.3.00.0080.00023.58
8.2.180.0210.00018.09
8.2.170.0070.01418.96
8.2.160.0100.00722.96
8.2.150.0070.00024.18
8.2.140.0050.00224.66
8.2.130.0080.00019.76
8.2.120.0060.00326.35
8.2.110.0000.01122.13
8.2.100.0040.00817.91
8.2.90.0040.00417.75
8.2.80.0080.00018.62
8.2.70.0080.00017.63
8.2.60.0090.00018.34
8.2.50.0110.00018.10
8.2.40.0000.00819.30
8.2.30.0040.00419.42
8.2.20.0070.00018.13
8.2.10.0050.00319.95
8.2.00.0000.00819.39
8.1.280.0150.00025.92
8.1.270.0000.00721.97
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0070.00321.04
8.1.230.0080.00320.87
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0040.00417.36
8.1.190.0030.00517.13
8.1.180.0050.00218.10
8.1.170.0040.00418.71
8.1.160.0030.00518.94
8.1.150.0000.00718.76
8.1.140.0040.00417.70
8.1.130.0030.00319.02
8.1.120.0070.00017.44
8.1.110.0050.00317.34
8.1.100.0080.00417.52
8.1.90.0000.00717.52
8.1.80.0000.00817.43
8.1.70.0070.00017.43
8.1.60.0060.00317.57
8.1.50.0050.00317.59
8.1.40.0080.00017.59
8.1.30.0070.00317.73
8.1.20.0040.00417.55
8.1.10.0000.00717.43
8.1.00.0050.00317.38
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0000.00718.42
8.0.270.0000.00716.84
8.0.260.0030.00317.27
8.0.250.0030.00316.88
8.0.240.0040.00417.01
8.0.230.0000.00716.98
8.0.220.0000.00716.82
8.0.210.0020.00516.88
8.0.200.0040.00416.84
8.0.190.0040.00416.92
8.0.180.0000.00816.93
8.0.170.0030.00616.98
8.0.160.0040.00416.84
8.0.150.0040.00716.76
8.0.140.0000.00816.80
8.0.130.0020.00513.35
8.0.120.0040.00416.83
8.0.110.0080.00016.99
8.0.100.0040.00416.73
8.0.90.0070.00016.91
8.0.80.0080.01016.89
8.0.70.0040.00416.80
8.0.60.0040.00416.80
8.0.50.0080.00016.94
8.0.30.0120.00617.15
8.0.20.0130.01017.40
8.0.10.0030.00616.99
8.0.00.0100.00716.56
7.4.330.0050.00015.55
7.4.320.0030.00316.62
7.4.300.0060.00016.62
7.4.290.0000.00716.45
7.4.280.0040.00416.40
7.4.270.0070.00016.53
7.4.260.0040.00416.64
7.4.250.0050.00316.60
7.4.240.0000.00716.60
7.4.230.0000.00716.62
7.4.220.0050.00316.64
7.4.210.0070.00816.68
7.4.200.0030.00316.32
7.4.160.0100.01016.61
7.4.140.0110.00717.86
7.4.130.0100.01016.62
7.4.120.0090.00916.59
7.4.110.0060.01216.36
7.4.100.0090.01216.55
7.4.90.0060.01216.60
7.4.80.0070.01419.39
7.4.70.0090.00616.52
7.4.60.0030.01316.56
7.4.50.0030.01316.39
7.4.40.0160.00616.55
7.4.10.0160.00416.40
7.4.00.0110.00615.54
7.3.330.0020.00213.25
7.3.320.0000.00613.34
7.3.310.0000.00716.32
7.3.300.0070.00016.33
7.3.290.0000.00816.34
7.3.280.0100.00816.37
7.3.260.0090.01216.49
7.3.240.0080.00916.49
7.3.230.0070.01016.71
7.3.210.0070.01016.31
7.3.200.0050.01116.47
7.3.190.0150.00316.27
7.3.180.0100.00616.39
7.3.170.0110.00516.56
7.3.160.0120.00816.39
7.3.130.0100.00316.59
7.3.120.0120.00515.59
7.3.110.0090.00515.61
7.3.100.0070.00715.76
7.3.90.0070.00615.48
7.3.80.0050.00615.74
7.3.70.0040.00615.71
7.3.60.0030.01215.53
7.3.50.0080.00215.66
7.3.40.0070.00815.72
7.3.30.0020.00815.68
7.3.20.0030.01017.34
7.3.10.0060.00617.40
7.3.00.0020.01117.45
7.2.330.0070.01116.51
7.2.320.0100.01016.87
7.2.310.0090.00916.84
7.2.300.0140.00316.66
7.2.290.0120.01216.89
7.2.260.0100.01016.63
7.2.250.0070.01115.90
7.2.240.0070.01115.88
7.2.230.0080.00715.92
7.2.220.0060.00515.88
7.2.210.0020.01515.73
7.2.200.0060.00815.81
7.2.190.0060.00815.83
7.2.180.0050.00515.64
7.2.170.0080.00315.88
7.2.160.0040.01416.59
7.2.150.0070.00718.33
7.2.140.0120.00318.43
7.2.130.0040.00718.38
7.2.120.0100.01018.32
7.2.110.0070.01418.45
7.2.100.0030.00918.43
7.2.90.0000.01618.51
7.2.80.0030.01618.28
7.2.70.0030.01018.35
7.2.60.0160.00916.75
7.2.50.0160.00816.54
7.2.40.0190.00916.67
7.2.30.0160.01016.77
7.2.20.0160.01116.48
7.2.10.0210.00616.62
7.2.00.0170.00816.75
7.1.330.0040.01316.69
7.1.320.0060.00516.65
7.1.310.0070.00916.67
7.1.300.0090.00416.71
7.1.290.0080.00616.52
7.1.280.0060.00716.67
7.1.270.0060.00616.67
7.1.260.0060.00916.49
7.1.250.0100.00317.32
7.1.240.0040.01117.44
7.1.230.0070.00717.25
7.1.220.0080.00317.44
7.1.210.0110.00717.36
7.1.200.0050.00916.44
7.1.190.0090.00617.35
7.1.180.0060.00617.34
7.1.170.0130.01115.61
7.1.160.0170.01115.63
7.1.150.0160.00715.47
7.1.140.0190.00515.49
7.1.130.0200.00515.60
7.1.120.0190.00315.52
7.1.110.0440.00515.64
7.1.100.0160.00515.64
7.1.90.0250.00315.49
7.1.80.0220.00415.54
7.1.70.0270.00515.57
7.1.60.0300.01024.62
7.1.50.0390.00624.60
7.1.40.0310.00924.58
7.1.30.0420.00724.60
7.1.20.0270.00724.64
7.1.10.0190.00915.49
7.1.00.0230.00516.51
7.0.330.0090.00617.15
7.0.320.0040.01417.06
7.0.310.0060.00916.88
7.0.300.0030.01316.99
7.0.290.0060.00617.05
7.0.280.0070.00717.04
7.0.270.0070.00716.95
7.0.260.0040.01117.13
7.0.250.0100.00717.04
7.0.240.0110.00417.02
7.0.230.0060.00917.06
7.0.220.0060.00916.91
7.0.210.0090.00317.04
7.0.200.0120.00316.85
7.0.190.0040.01217.04
7.0.180.0090.00317.06
7.0.170.0100.00717.00
7.0.160.0080.00616.93
7.0.150.0070.00717.04
7.0.140.0100.00717.00
7.0.130.0030.00917.07
7.0.120.0080.00417.18
7.0.110.0030.00717.21
7.0.100.0030.00616.97
7.0.90.0060.00917.08
7.0.80.0030.01217.14
7.0.70.0000.00916.93
7.0.60.0100.00316.89
7.0.50.0030.01016.83
7.0.40.0090.00615.03
7.0.30.0040.00815.02
7.0.20.0040.01114.75
7.0.10.0030.01214.94
7.0.00.0090.00615.00
5.6.400.0000.01015.67
5.6.390.0090.00915.78
5.6.380.0110.00615.72
5.6.370.0120.00615.79
5.6.360.0070.01015.77
5.6.350.0040.01515.97
5.6.340.0030.01315.68
5.6.330.0080.00815.88
5.6.320.0000.01016.23
5.6.310.0070.00415.96
5.6.300.0040.01115.84
5.6.290.0070.00316.09
5.6.280.0070.00415.95
5.6.270.0070.00416.08
5.6.260.0030.01215.98
5.6.250.0070.01116.07
5.6.240.0030.01015.78
5.6.230.0070.00416.20
5.6.220.0030.00616.24
5.6.210.0100.00716.18
5.6.200.0080.00816.01
5.6.190.0080.00315.71
5.6.180.0060.00715.85
5.6.170.0000.01215.83
5.6.160.0060.00915.88
5.6.150.0100.00615.88
5.6.140.0030.01016.12
5.6.130.0030.00615.90
5.6.120.0030.01216.11
5.6.110.0090.00615.89
5.6.100.0000.01316.00
5.6.90.0100.00615.94
5.6.80.0040.00815.71
5.6.70.0070.00715.70
5.6.60.0030.00715.76
5.6.50.0040.01115.68
5.6.40.0000.00915.71
5.6.30.0030.01016.10
5.6.20.0090.00315.89
5.6.10.0100.00315.70
5.6.00.0080.00415.75

preferences:
38.98 ms | 400 KiB | 5 Q