3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$xml = simplexml_load_file('data.xml'); $xml = simplexml_load_string('<items> <item> <images> <image>A</image> <image>B</image> <image>C</image> </images> </item> </items>'); //var_dump($xml); // Loop over items in original xml foreach ($xml->item as $item) { if ($item->images->image->count() > 1) { // Clone entry $images = clone $item->images; // Remove entry and replace with empty unset($item->images); $item->addChild('images'); foreach ($images->image as $key => $img ) { $name = 'image' . ($key) ?: ''; $item->images->addChild($name, $img); } } } //$xml->asXML('POTO.xml'); echo $xml->asXML();

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.0110.01118.55
8.3.60.0110.00418.71
8.3.50.0150.00221.21
8.3.40.0100.01018.88
8.3.30.0140.00720.50
8.3.20.0110.00720.59
8.3.10.0070.01022.29
8.3.00.0140.00422.64
8.2.180.0060.01216.75
8.2.170.0070.01022.96
8.2.160.0130.00020.77
8.2.150.0080.00024.18
8.2.140.0120.00624.66
8.2.130.0080.00026.16
8.2.120.0080.00019.79
8.2.110.0060.00321.08
8.2.100.0070.00718.16
8.2.90.0040.00419.52
8.2.80.0000.00817.97
8.2.70.0000.00917.88
8.2.60.0040.00418.18
8.2.50.0040.00818.10
8.2.40.0040.00418.47
8.2.30.0030.00518.25
8.2.20.0050.00318.02
8.2.10.0000.00818.02
8.2.00.0000.00817.94
8.1.280.0140.00725.92
8.1.270.0070.00024.66
8.1.260.0000.00926.35
8.1.250.0060.00328.09
8.1.240.0040.00424.16
8.1.230.0030.00717.96
8.1.220.0000.00817.90
8.1.210.0040.00418.77
8.1.200.0060.00317.61
8.1.190.0080.00017.25
8.1.180.0000.00818.10
8.1.170.0040.00418.83
8.1.160.0080.00022.40
8.1.150.0050.00218.91
8.1.140.0050.00317.71
8.1.130.0040.00718.15
8.1.120.0040.00417.63
8.1.110.0000.00717.64
8.1.100.0040.00417.80
8.1.90.0030.00517.77
8.1.80.0040.00417.72
8.1.70.0030.00517.73
8.1.60.0050.00317.86
8.1.50.0040.00417.80
8.1.40.0080.00017.72
8.1.30.0040.00417.77
8.1.20.0040.00417.90
8.1.10.0000.00817.90
8.1.00.0000.00717.81
8.0.300.0040.00418.77
8.0.290.0000.00717.13
8.0.280.0030.00818.60
8.0.270.0030.00317.54
8.0.260.0030.00317.00
8.0.250.0000.00717.21
8.0.240.0000.00717.12
8.0.230.0000.00717.21
8.0.220.0040.00317.14
8.0.210.0030.00317.06
8.0.200.0060.00317.30
8.0.190.0030.00517.28
8.0.180.0040.00417.18
8.0.170.0040.00417.21
8.0.160.0080.00017.16
8.0.150.0000.00817.07
8.0.140.0000.00717.11
8.0.130.0030.00313.55
8.0.120.0040.00417.07
8.0.110.0080.00017.17
8.0.100.0000.00717.21
8.0.90.0040.00417.02
8.0.80.0100.00717.21
8.0.70.0000.00717.12
8.0.60.0040.00417.00
8.0.50.0020.00517.05
8.0.30.0110.00817.48
8.0.20.0080.01017.40
8.0.10.0030.00517.13
8.0.00.0090.01217.03
7.4.330.0030.00315.00
7.4.320.0000.00616.88
7.4.300.0000.00816.77
7.4.290.0000.00716.93
7.4.280.0030.00316.90
7.4.270.0040.00416.79
7.4.260.0050.00316.79
7.4.250.0000.00716.79
7.4.240.0050.00216.78
7.4.230.0030.00317.00
7.4.220.0120.00916.79
7.4.210.0100.00516.86
7.4.200.0000.00716.82
7.4.190.0030.00316.89
7.4.160.0100.00716.86
7.4.150.0110.00717.40
7.4.140.0090.01217.86
7.4.130.0060.01016.74
7.4.120.0130.00616.74
7.4.110.0070.01016.82
7.4.100.0140.00816.82
7.4.90.0040.01316.69
7.4.80.0090.00919.39
7.4.70.0100.00716.80
7.4.60.0090.00916.75
7.4.50.0030.00616.98
7.4.40.0000.01422.77
7.4.30.0130.00316.61
7.4.00.0070.00415.02
7.3.330.0060.00013.41
7.3.320.0000.00613.39
7.3.310.0040.00416.41
7.3.300.0030.00316.37
7.3.290.0120.00316.56
7.3.280.0090.00816.53
7.3.270.0080.00817.40
7.3.260.0040.01416.52
7.3.250.0110.00816.71
7.3.240.0040.01916.52
7.3.230.0130.01016.86
7.3.210.0070.01016.54
7.3.200.0140.00319.39
7.3.190.0160.00616.58
7.3.180.0090.00616.73
7.3.170.0170.00316.65
7.3.160.0060.01716.80
7.3.120.0040.00715.09
7.2.330.0100.00716.75
7.2.320.0080.00817.11
7.2.310.0100.01217.00
7.2.300.0100.01016.81
7.2.290.0040.01416.86
7.2.00.0030.00919.74
7.1.100.0030.01018.20
7.1.70.0000.01017.34
7.1.60.0070.01719.43
7.1.50.0160.00717.08
7.1.00.0030.03322.53
7.0.200.0000.00816.84
7.0.140.0030.09722.16
7.0.60.0100.05720.16
7.0.50.0100.07017.99
7.0.40.0030.04320.06
7.0.30.0230.09020.28
7.0.20.0270.04720.30
7.0.10.0230.05720.38
7.0.00.0130.08020.39
5.6.280.0030.07021.24
5.6.210.0000.08720.65
5.6.200.0100.07718.23
5.6.190.0070.08020.52
5.6.180.0170.05720.84
5.6.170.0230.05020.51
5.6.160.0030.08720.52
5.6.150.0100.07718.22
5.6.140.0070.08018.27
5.6.130.0070.03718.27
5.6.120.0000.05021.10
5.6.110.0070.08721.19
5.6.100.0030.08021.15
5.6.90.0100.07721.15
5.6.80.0130.07720.59
5.5.350.0070.08020.39
5.5.340.0070.08018.09
5.5.330.0170.05320.29
5.5.320.0270.04720.29
5.5.310.0230.07720.36
5.5.300.0100.04318.04
5.5.290.0070.08018.13
5.5.280.0130.07320.94
5.5.270.0070.08320.75
5.5.260.0000.09021.00
5.5.250.0070.03720.66
5.5.240.0030.06720.20
5.4.450.0870.05319.63
5.4.440.0200.06019.71
5.4.430.0100.06319.35
5.4.420.0170.05719.70
5.4.410.0170.05719.57
5.4.400.0570.06718.59
5.4.390.0370.05718.85
5.4.380.0500.03718.70
5.4.370.0170.05018.84
5.4.360.0130.05018.52
5.4.350.0060.03612.14
5.4.340.0100.03212.14
5.4.320.0030.03812.64
5.4.310.0040.04012.64
5.4.300.0040.03812.64
5.4.290.0050.05112.64
5.4.280.0030.03712.53
5.4.270.0080.04612.53
5.4.260.0050.03812.53
5.4.250.0100.05018.79
5.4.240.0200.04718.95
5.4.230.0170.04318.87
5.4.220.0170.05319.13
5.4.210.0070.05319.00
5.4.200.0270.04018.87
5.4.190.0200.04719.07
5.4.180.0070.05318.97
5.4.170.0130.05318.87
5.4.160.0070.07718.89
5.4.150.0170.04718.93
5.4.140.0030.05316.32
5.4.130.0070.04716.30
5.4.120.0200.03716.36
5.4.110.0030.05316.49
5.4.100.0030.05716.39
5.4.90.0070.04716.62
5.4.80.0200.06316.70
5.4.70.0070.05316.40
5.4.60.0070.04716.68
5.4.50.0070.05316.36
5.4.40.0100.04716.58
5.4.30.0070.04716.56
5.4.20.0070.04716.61
5.4.10.0030.08016.67
5.4.00.0030.05716.03
5.3.290.0060.03812.90
5.3.280.0100.05014.72
5.3.270.0070.05314.77
5.3.260.0070.05314.70
5.3.250.0070.05014.50
5.3.240.0130.04314.83
5.3.230.0070.06714.67
5.3.220.0030.05314.66
5.3.210.0030.05714.65
5.3.200.0070.05014.57
5.3.190.0070.05314.79
5.3.180.0170.04014.71
5.3.170.0070.05714.68
5.3.160.0070.05314.46
5.3.150.0100.06714.73
5.3.140.0200.03714.54
5.3.130.0000.06014.62
5.3.120.0170.06314.57
5.3.110.0030.05314.55
5.3.100.0030.05314.02
5.3.90.0100.05314.09
5.3.80.0100.04714.25
5.3.70.0000.05314.25
5.3.60.0130.04314.10
5.3.50.0170.04014.02
5.3.40.0070.05013.84
5.3.30.0100.04313.96
5.3.20.0030.05313.66
5.3.10.0100.05713.71
5.3.00.0170.04713.72
5.2.170.0070.04711.14
5.2.160.0100.03311.16
5.2.150.0130.03311.14
5.2.140.0130.03311.03
5.2.130.0030.04311.12
5.2.120.0030.04010.94
5.2.110.0070.04011.02
5.2.100.0100.03311.02
5.2.90.0030.05711.12
5.2.80.0000.04310.93
5.2.70.0030.04011.04
5.2.60.0130.04311.14
5.2.50.0030.05711.03
5.2.40.0030.04011.03
5.2.30.0070.04710.97
5.2.20.0130.05310.80
5.2.10.0070.04011.07
5.2.00.0130.04710.80
5.1.60.0030.0379.93
5.1.50.0030.0409.93
5.1.40.0030.03310.17
5.1.30.0100.05010.41
5.1.20.0070.03310.12
5.1.10.0100.03310.00
5.1.00.0070.03310.16
5.0.50.0070.0238.59
5.0.40.0130.0208.36
5.0.30.0100.0378.37
5.0.20.0000.0308.14
5.0.10.0030.0308.15
5.0.00.0030.0407.99
4.4.90.0000.0277.38
4.4.80.0030.0207.38
4.4.70.0070.0207.38
4.4.60.0100.0137.38
4.4.50.0030.0207.38
4.4.40.0030.0437.38
4.4.30.0030.0207.38
4.4.20.0070.0237.38
4.4.10.0000.0237.38
4.4.00.0000.0337.38
4.3.110.0000.0237.38
4.3.100.0030.0277.38
4.3.90.0030.0277.38
4.3.80.0000.0377.38
4.3.70.0000.0237.38
4.3.60.0030.0207.38
4.3.50.0000.0307.38
4.3.40.0070.0277.30
4.3.30.0030.0237.14
4.3.20.0030.0207.14
4.3.10.0000.0207.14
4.3.00.0100.0235.65

preferences:
68.63 ms | 401 KiB | 5 Q