3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arrayToXml($array, \SimpleXMLElement $xml) { foreach ($array as $key => $value) { if (is_array($value)) { if (!is_numeric($key)) { $subNode = $xml->addChild($key); } else { $subNode = $xml->addChild('item' . $key); } arrayToXml($value, $subNode); } else { $xml->addChild($key, htmlspecialchars($value)); } } } $array = [ 'key' => 'value', 'arrKey' => [ 'subkey1' => 1, 'subkey2' => 2, ], 0 => 'numeric zero', 1 => 'another', 2 => [ 'adin', 'two', 'three' ], ]; $xml = new \SimpleXMLElement('<response/>'); arrayToXml($array, $xml); echo $xml->asXML(); echo PHP_EOL; $xml = new SimpleXMLElement('<response/>'); array_walk_recursive(array_flip($array), array ($xml, 'addChild')); print $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.60.0040.01116.88
8.3.50.0110.00721.34
8.3.40.0090.00619.05
8.3.30.0000.01419.09
8.3.20.0040.00420.58
8.3.10.0040.00421.96
8.3.00.0080.00019.81
8.2.180.0130.00617.13
8.2.170.0120.00622.96
8.2.160.0100.00720.69
8.2.150.0040.00424.18
8.2.140.0110.00724.66
8.2.130.0040.00426.16
8.2.120.0040.00418.00
8.2.110.0090.00021.29
8.2.100.0110.00018.16
8.2.90.0080.00318.13
8.2.80.0000.00819.61
8.2.70.0030.00518.18
8.2.60.0060.00318.18
8.2.50.0030.00618.10
8.2.40.0020.00520.88
8.2.30.0040.00420.07
8.2.20.0040.00417.81
8.2.10.0080.00018.24
8.2.00.0040.00418.48
8.1.280.0070.00725.92
8.1.270.0110.00420.45
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0000.00822.30
8.1.230.0100.00019.18
8.1.220.0040.00418.04
8.1.210.0030.00618.77
8.1.200.0060.00317.48
8.1.190.0060.00317.50
8.1.180.0040.00418.10
8.1.170.0030.00518.91
8.1.160.0050.00222.31
8.1.150.0000.00719.10
8.1.140.0030.00517.70
8.1.130.0030.00517.84
8.1.120.0040.00417.79
8.1.110.0000.00817.74
8.1.100.0050.00217.70
8.1.90.0000.00817.62
8.1.80.0000.00817.61
8.1.70.0070.00017.61
8.1.60.0030.00617.70
8.1.50.0040.00417.79
8.1.40.0000.00817.78
8.1.30.0000.00817.78
8.1.20.0060.00317.94
8.1.10.0080.00017.83
8.1.00.0080.00017.79
8.0.300.0040.00420.02
8.0.290.0030.00717.13
8.0.280.0000.00718.73
8.0.270.0030.00517.43
8.0.260.0000.00617.50
8.0.250.0030.00517.24
8.0.240.0000.00717.25
8.0.230.0050.00317.37
8.0.220.0050.00217.12
8.0.210.0000.00717.26
8.0.200.0000.00617.22
8.0.190.0080.00017.11
8.0.180.0040.00417.25
8.0.170.0090.00017.25
8.0.160.0080.00017.11
8.0.150.0050.00317.06
8.0.140.0000.00817.19
8.0.130.0040.00413.67
8.0.120.0000.00817.20
8.0.110.0000.00717.21
8.0.100.0000.00717.25
8.0.90.0050.00317.20
8.0.80.0120.00317.19
8.0.70.0040.00417.17
8.0.60.0000.00717.11
8.0.50.0030.00517.05
8.0.30.0130.00717.38
8.0.20.0080.01117.40
8.0.10.0040.00417.31
8.0.00.0110.00917.22
7.4.330.0060.00015.25
7.4.320.0000.00716.84
7.4.300.0000.00616.80
7.4.290.0050.00316.68
7.4.280.0030.00616.70
7.4.270.0040.00416.79
7.4.260.0070.00016.80
7.4.250.0060.00316.87
7.4.240.0040.00316.87
7.4.230.0000.00716.93
7.4.220.0060.01216.68
7.4.210.0080.00816.96
7.4.200.0040.00416.83
7.4.160.0000.01616.66
7.4.150.0100.01017.40
7.4.140.0080.01117.86
7.4.130.0090.00916.75
7.4.120.0080.01116.85
7.4.110.0130.00416.82
7.4.100.0110.01116.89
7.4.90.0180.00016.71
7.4.80.0090.01219.39
7.4.70.0100.00716.94
7.4.60.0100.00616.64
7.4.50.0000.00916.41
7.4.40.0060.01316.86
7.4.30.0090.01516.95
7.4.00.0000.01014.98
7.3.330.0050.00013.44
7.3.320.0050.00013.39
7.3.310.0070.00016.65
7.3.300.0030.00316.56
7.3.290.0080.00916.63
7.3.280.0070.01016.66
7.3.270.0000.01717.40
7.3.260.0000.01716.89
7.3.250.0090.00816.80
7.3.240.0030.01416.90
7.3.230.0110.01216.73
7.3.210.0080.00816.71
7.3.200.0050.01116.85
7.3.190.0100.00716.93
7.3.180.0040.01216.61
7.3.170.0170.00016.79
7.3.160.0140.00316.64
7.2.330.0100.00716.79
7.2.320.0070.01617.02
7.2.310.0060.01116.90
7.2.300.0110.00616.86
7.2.290.0090.00917.16
7.2.60.0060.00916.92
7.2.00.0000.01519.69
7.1.200.0040.00816.16
7.1.100.0120.00018.07
7.1.70.0000.00717.06
7.1.60.0090.01620.03
7.1.50.0140.01016.65
7.1.00.0070.07322.61
7.0.200.0040.00416.61
7.0.60.0170.07020.14
7.0.50.0100.06017.97
7.0.40.0070.04020.39
7.0.30.0270.07020.41
7.0.20.0270.08720.19
7.0.10.0130.03320.23
7.0.00.0100.03720.22
5.6.280.0070.03021.09
5.6.210.0070.07720.69
5.6.200.0100.08018.32
5.6.190.0100.04720.55
5.6.180.0230.08320.55
5.6.170.0270.06720.60
5.6.160.0170.03720.68
5.6.150.0130.07318.36
5.6.140.0070.07018.38
5.6.130.0030.09018.20
5.6.120.0130.04021.06
5.6.110.0070.08321.03
5.6.100.0100.08021.03
5.6.90.0170.05721.18
5.6.80.0130.04320.47
5.5.350.2870.05320.46
5.5.340.0130.07318.17
5.5.330.0030.04020.37
5.5.320.0170.06020.43
5.5.310.0570.06320.38
5.5.300.0000.04718.19
5.5.290.0070.08318.00
5.5.280.0100.08321.07
5.5.270.0070.05021.09
5.5.260.0100.08721.07
5.5.250.0100.08320.71
5.5.240.0000.08320.25
5.4.450.0130.06019.70
5.4.440.0170.05719.69
5.4.430.0170.05319.55
5.4.420.0200.05019.66
5.4.410.0130.05719.29
5.4.400.0130.05719.23
5.4.390.0200.05019.38
5.4.380.0200.04719.38
5.4.370.0130.05319.18
5.4.360.0170.05719.34
5.4.350.0170.05719.06
5.4.340.0100.06319.39
5.4.320.0130.05719.23
5.4.310.0070.06019.36
5.4.300.0170.05319.36
5.4.290.0170.05019.05
5.4.280.0270.04319.40
5.4.270.0200.04719.20
5.4.260.0170.05319.23
5.4.250.0300.03719.35
5.4.240.0100.05719.45
5.4.230.0200.04719.33
5.4.220.0070.06319.22
5.4.210.0130.05319.45
5.4.200.0230.04319.39
5.4.190.0200.05019.22
5.4.180.0100.05719.21
5.4.170.0170.05019.16
5.4.160.0130.05319.13
5.4.150.0270.04319.20
5.4.140.0270.04016.55
5.4.130.0200.05016.52
5.4.120.0130.05316.52
5.4.110.0070.06016.66
5.4.100.0100.05316.76
5.4.90.0270.03716.78
5.4.80.0130.05016.63
5.4.70.0230.07016.63
5.4.60.0170.07716.58
5.4.50.0270.07016.47
5.4.40.0330.05716.68
5.4.30.0030.07316.50
5.4.20.0230.04316.47
5.4.10.0300.05316.68

preferences:
38.23 ms | 401 KiB | 5 Q