3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = '<?xml version="1.0" encoding="utf-8"?> <products> <item> <ItemID>01</ItemID> <ItemName>Book</ItemName> </item> <Product> <ProductID>01</ProductID> <ProductName>Paper</ProductName> </Product>'; $lines = explode("\n", $str); $output = ""; $arrayLength = count($lines); for ($i = 0; $i < $arrayLength; $i++) { $trimmedNextLine = isset($lines[$i + 1]) ? trim($lines[$i + 1]) : null; $line = $lines[$i]; if ($trimmedNextLine == "<Product>") { $output .= $line . $trimmedNextLine; $i++; } else { $output .= $line; } if ($i < $arrayLength) { $output .= "\n"; } } echo $output;

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.70.0040.00418.53
8.5.60.0090.00816.94
8.5.50.0080.01216.58
8.5.30.0120.00617.57
8.5.20.0090.00819.64
8.5.10.0070.01120.11
8.5.00.0150.00719.82
8.4.210.0080.01219.65
8.4.180.0140.00819.45
8.4.170.0140.00720.63
8.4.160.0140.01120.42
8.4.150.0070.00516.87
8.4.140.0040.00517.68
8.4.130.0160.00417.82
8.4.120.0140.00622.32
8.4.110.0080.00422.37
8.4.100.0100.01117.66
8.4.90.0160.00518.70
8.4.80.0060.00317.89
8.4.70.0090.01117.68
8.4.60.0050.00418.86
8.4.50.0120.00817.76
8.4.40.0060.01219.58
8.4.30.0040.01118.97
8.4.20.0060.01519.89
8.4.10.0060.00322.19
8.3.300.0110.01119.37
8.3.290.0140.00820.78
8.3.280.0110.00918.43
8.3.270.0130.00616.86
8.3.260.0050.00416.46
8.3.250.0050.00419.10
8.3.240.0110.00816.44
8.3.230.0140.00616.54
8.3.220.0060.00317.05
8.3.210.0120.00716.73
8.3.200.0050.00616.61
8.3.190.0060.00617.38
8.3.180.0130.00916.69
8.3.170.0040.00419.10
8.3.160.0070.00316.62
8.3.150.0120.00620.90
8.3.140.0080.00016.73
8.3.130.0030.00516.51
8.3.120.0030.00620.84
8.3.110.0160.00320.94
8.3.100.0060.00324.06
8.3.90.0030.00526.77
8.3.80.0040.00418.28
8.3.70.0110.00716.58
8.3.60.0120.00316.50
8.3.50.0140.00318.51
8.3.40.0030.01020.30
8.3.30.0100.00718.75
8.3.20.0040.00424.18
8.3.10.0100.00024.66
8.3.00.0030.00526.16
8.2.300.0110.00920.29
8.2.290.0060.00320.53
8.2.280.0050.00318.47
8.2.270.0120.00817.38
8.2.260.0000.00818.51
8.2.250.0080.00018.32
8.2.240.0060.00316.93
8.2.230.0040.00422.58
8.2.220.0060.00637.54
8.2.210.0040.00426.77
8.2.200.0060.00616.62
8.2.190.0110.00416.58
8.2.180.0130.00325.92
8.2.170.0100.01018.89
8.2.160.0000.02122.96
8.2.150.0050.00325.66
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00426.16
8.2.110.0060.00320.47
8.2.100.0070.00717.68
8.2.90.0050.00317.88
8.2.80.0030.00518.73
8.2.70.0030.00617.63
8.2.60.0000.00817.93
8.2.50.0040.00718.07
8.2.40.0050.00320.07
8.2.30.0050.00218.18
8.2.20.0070.00019.31
8.2.10.0000.00718.20
8.2.00.0040.00419.20
8.1.340.0120.01020.20
8.1.330.0080.00422.18
8.1.320.0130.00716.20
8.1.310.0090.00918.25
8.1.300.0070.01118.15
8.1.290.0030.00630.84
8.1.280.0090.00625.92
8.1.270.0070.00024.66
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0090.00019.06
8.1.230.0070.00717.57
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0040.00417.35
8.1.190.0000.00817.22
8.1.180.0000.00818.10
8.1.170.0040.00418.54
8.1.160.0030.00718.91
8.1.150.0100.00018.64
8.1.140.0030.00517.49
8.1.130.0070.00017.34
8.1.120.0070.00017.51
8.1.110.0040.00417.38
8.1.100.0000.01017.36
8.1.90.0100.00517.48
8.1.80.0090.00617.32
8.1.70.0130.00217.34
8.1.60.0090.00917.60
8.1.50.0140.00417.49
8.1.40.0140.00317.56
8.1.30.0090.00917.56
8.1.20.0090.00917.67
8.1.10.0110.00517.48
8.1.00.0140.00317.56
8.0.300.0000.00718.77
8.0.290.0000.00716.75
8.0.280.0000.00818.47
8.0.270.0070.00016.89
8.0.260.0030.00316.71
8.0.250.0000.00716.84
8.0.240.0070.00016.95
8.0.230.0080.00716.80
8.0.220.0140.00016.91
8.0.210.0070.00716.93
8.0.200.0160.00016.84
8.0.190.0110.00416.82
8.0.180.0110.00417.00
8.0.170.0090.00516.81
8.0.160.0140.00016.75
8.0.150.0120.00216.81
8.0.140.0090.00516.83
8.0.130.0110.00316.69
8.0.120.0050.00916.95
8.0.110.0080.00516.72
8.0.100.0070.00716.74
8.0.90.0120.00316.93
8.0.80.0100.00516.77
8.0.70.0140.00016.68
8.0.60.0070.00716.67
8.0.50.0140.00016.84
8.0.30.0090.00416.90
8.0.20.0100.00316.96
8.0.10.0100.00317.06
7.4.330.0050.00015.55
7.4.320.0040.00416.54
7.4.300.0080.00816.53
7.4.290.0120.00516.47
7.4.280.0150.00216.60
7.4.270.0140.00316.44
7.4.260.0080.00816.61
7.4.250.0130.00416.61
7.4.240.0150.00016.57
7.4.230.0160.00016.53
7.4.220.0110.00416.50
7.4.210.0070.00716.65
7.4.200.0070.00716.66
7.4.190.0080.00516.59
7.4.180.0140.00016.59
7.4.160.0070.00716.57
7.4.150.0100.00316.51
7.4.140.0070.00716.48
7.4.130.0130.00316.39
7.4.120.0120.00216.47
7.4.110.0070.00716.55
7.4.100.0140.00016.63
7.4.90.0000.01316.24
7.4.80.0140.00016.48
7.4.70.0090.00416.48
7.4.60.0080.00616.56
7.4.50.0100.00316.39
7.4.40.0090.00316.36
7.4.30.0030.00916.57
7.4.20.0040.00916.38
7.4.10.0060.00616.30
7.4.00.0090.00416.48

preferences:
53.6 ms | 1288 KiB | 5 Q