3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_to_xml(array $data) { $document = new DOMDocument(); array_to_xml_aux($data, $document); $document->formatOutput = true; return $document; } function array_to_xml_aux(array $data, DOMNode $parent, $name = null) { foreach ($data as $key => $value) { if ($key[0] == '@') { $parent->setAttribute( substr($key, 1), $value ); return; } if (is_numeric($key)) { $key = $name; } if (is_array($value)) { $subnode = new DOMElement($key); $parent->appendChild($subnode); array_to_xml_aux($value, $subnode, $key); } else { $xml_data->appendChild(new DOMElement($key, $value)); } } } $document = array_to_xml( array( 'Products' => array( 'Product' => array('@name' => 'TR-501'), 'Descricao' => array('@text' => '55.180.198 / 46789771'), 'Detalhes' => array( 'Variacao' => array( array( '@modelo' => 'Palio', '@ano' => '2006', '@motor' => '1.0 FIRE 8V (FLEX)', ), array( '@modelo' => 'Palio2', '@ano' => '2007', '@motor' => '1.0 FIRE 9V (FLEX)', ), ) ), ) ) ); echo $document->saveXML();

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.130.0100.00017.05
8.3.120.0050.00320.81
8.3.110.0000.00816.93
8.3.100.0030.00618.57
8.3.90.0000.01526.77
8.3.80.0060.00319.36
8.3.70.0090.01318.55
8.3.60.0110.01117.13
8.3.50.0150.00618.60
8.3.40.0060.01019.04
8.3.30.0150.00019.14
8.3.20.0080.00022.08
8.3.10.0000.00823.73
8.3.00.0000.00819.81
8.2.250.0070.01119.00
8.2.240.0110.00417.70
8.2.230.0100.01020.94
8.2.220.0050.00324.06
8.2.210.0040.00426.77
8.2.200.0080.00318.88
8.2.190.0070.00716.60
8.2.180.0120.00418.67
8.2.170.0110.00422.96
8.2.160.0140.00319.29
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0100.00019.36
8.2.120.0080.00026.35
8.2.110.0030.00621.19
8.2.100.0040.00819.88
8.2.90.0040.00418.13
8.2.80.0060.00318.77
8.2.70.0050.00317.88
8.2.60.0000.00817.75
8.2.50.0090.00017.88
8.2.40.0030.00519.60
8.2.30.0000.00719.64
8.2.20.0050.00318.35
8.2.10.0080.00018.23
8.2.00.0040.00418.37
8.1.300.0090.00018.61
8.1.290.0030.00630.84
8.1.280.0070.01425.92
8.1.270.0030.00624.13
8.1.260.0090.00026.35
8.1.250.0040.00728.09
8.1.240.0040.00419.47
8.1.230.0110.00019.36
8.1.220.0040.00418.76
8.1.210.0050.00318.77
8.1.200.0090.00017.61
8.1.190.0000.00917.47
8.1.180.0000.00822.24
8.1.170.0040.00417.62
8.1.160.0040.00419.12
8.1.150.0030.00319.12
8.1.140.0000.00717.89
8.1.130.0020.00619.74
8.1.120.0060.00518.32
8.1.110.0100.00318.26
8.1.100.0040.00818.30
8.1.90.0110.00118.26
8.1.80.0060.00618.23
8.1.70.0090.00418.32
8.1.60.0100.00418.37
8.1.50.0050.00818.37
8.1.40.0060.00618.41
8.1.30.0070.00618.44
8.1.20.0120.00218.47
8.1.10.0080.00518.36
8.1.00.0130.00318.28
8.0.300.0000.00718.77
8.0.290.0000.00716.88
8.0.280.0000.00718.66
8.0.270.0030.00317.05
8.0.260.0090.00518.31
8.0.250.0090.00217.75
8.0.240.0040.00817.71
8.0.230.0090.00217.77
8.0.220.0060.00617.68
8.0.210.0050.00617.66
8.0.200.0040.00617.79
8.0.190.0090.00117.71
8.0.180.0080.00317.81
8.0.170.0060.00517.71
8.0.160.0090.00217.78
8.0.150.0090.00217.66
8.0.140.0060.00417.66
8.0.130.0070.00315.91
8.0.120.0040.00717.69
8.0.110.0050.00617.60
8.0.100.0080.00317.57
8.0.90.0060.00517.54
8.0.80.0040.01117.70
8.0.70.0020.00817.72
8.0.60.0050.00617.72
8.0.50.0070.00417.69
8.0.30.0130.00917.52
8.0.20.0140.00717.46
8.0.10.0140.00817.61
8.0.00.0130.00717.36
7.4.330.0070.00215.56
7.4.320.0060.00617.28
7.4.300.0080.00317.32
7.4.290.0120.00017.19
7.4.280.0080.00517.30
7.4.270.0080.00317.32
7.4.260.0090.00417.27
7.4.250.0080.00417.33
7.4.240.0050.00617.33
7.4.230.0080.00317.32
7.4.220.0040.00617.13
7.4.210.0050.00717.10
7.4.200.0040.00517.20
7.4.190.0020.00717.85
7.4.180.0050.00517.84
7.4.160.0110.00717.17
7.4.150.0110.00817.09
7.4.140.0100.00917.55
7.4.130.0090.01116.96
7.4.120.0110.00817.10
7.4.110.0110.00816.90
7.4.100.0140.00717.03
7.4.90.0090.01016.97
7.4.80.0070.01317.62
7.4.70.0160.00516.98
7.4.60.0130.00716.98
7.4.50.0100.00817.01
7.4.40.0100.01016.95
7.4.30.0140.00616.98
7.4.20.0150.00517.05
7.4.10.0160.00617.15
7.4.00.0110.00916.58
7.3.330.0020.00815.48
7.3.320.0070.00315.56
7.3.310.0030.00717.03
7.3.300.0060.00417.07
7.3.290.0060.00417.09
7.3.280.0140.00516.78
7.3.270.0130.00816.90
7.3.260.0130.00716.75
7.3.250.0130.00816.89
7.3.240.0110.00816.71
7.3.230.0150.00516.87
7.3.220.0150.00816.90
7.3.210.0140.00716.70
7.3.200.0140.00616.75
7.3.190.0110.00916.76
7.3.180.0130.00816.82
7.3.170.0110.01016.79
7.3.160.0110.01116.89
7.3.150.0160.00716.92
7.3.140.0140.00616.79
7.3.130.0130.00816.85
7.3.120.0120.00717.51
7.3.110.0100.00916.38
7.3.100.0110.00916.32
7.3.90.0120.00616.56
7.3.80.0120.00916.35
7.3.70.0120.00716.40
7.3.60.0150.00616.49
7.3.50.0120.00916.46
7.3.40.0130.00616.53
7.3.30.0140.00516.49
7.3.20.0110.00717.03
7.3.10.0100.00716.94
7.3.00.0110.01016.79
7.2.340.0160.00716.99
7.2.330.0150.00417.09
7.2.320.0140.00917.07
7.2.310.0110.01016.98
7.2.300.0110.00917.03
7.2.290.0140.00917.11
7.2.280.0130.00717.10
7.2.270.0150.00517.02
7.2.260.0160.00617.09
7.2.250.0140.00717.11
7.2.240.0120.00716.60
7.2.230.0110.00816.62
7.2.220.0130.01016.59
7.2.210.0120.00616.57
7.2.200.0110.01016.75
7.2.190.0120.00816.74
7.2.180.0100.01016.63
7.2.170.0150.00516.70
7.2.160.0110.00916.62
7.2.150.0130.00717.12
7.2.140.0120.01017.08
7.2.130.0120.00917.22
7.2.120.0150.00717.23
7.2.110.0120.00917.21
7.2.100.0110.00717.14
7.2.90.0120.00817.24
7.2.80.0120.01117.20
7.2.70.0140.00717.21
7.2.60.0100.00817.21
7.2.50.0130.00717.12
7.2.40.0250.00917.52
7.2.30.0530.01017.59
7.2.20.0280.01017.44
7.2.10.0350.00917.47
7.2.00.0600.00917.60
7.1.330.0150.00616.13
7.1.320.0130.00516.15
7.1.310.0130.00916.13
7.1.300.0130.00716.14
7.1.290.0130.00716.13
7.1.280.0170.00215.99
7.1.270.0130.00816.07
7.1.260.0140.00416.08
7.1.250.0130.00516.02
7.1.240.0130.00716.07
7.1.230.0160.00816.10
7.1.220.0170.00516.03
7.1.210.0090.01116.05
7.1.200.0150.00516.01
7.1.190.0170.00416.03
7.1.180.0120.00916.03
7.1.170.0160.00915.97
7.1.160.0660.00716.33
7.1.150.0390.00916.31
7.1.140.0500.00916.40
7.1.130.0340.00916.24
7.1.120.0480.00916.40
7.1.110.0550.01016.17
7.1.100.0280.00816.14
7.1.90.0310.01016.13
7.1.80.0270.00916.20
7.1.70.0320.01115.71
7.1.60.0580.01221.83
7.1.50.0490.01021.73
7.1.40.0490.01021.63
7.1.30.0500.01221.59
7.1.20.0400.00821.65
7.1.10.0280.00915.56
7.1.00.0320.00915.61
7.0.330.0110.00815.61
7.0.320.0130.00516.32
7.0.310.0130.00616.36
7.0.300.0110.00816.38
7.0.290.0130.00816.32
7.0.280.0140.01016.42
7.0.270.0170.00816.34
7.0.260.0170.00616.37
7.0.250.0090.01016.57
7.0.240.0160.00316.50
7.0.230.0140.00916.44
7.0.220.0100.01116.41
7.0.210.0150.00816.50
7.0.200.0110.00616.39
7.0.190.0150.01016.38
7.0.180.0170.00616.47
7.0.170.0150.00716.55
7.0.160.0140.00816.44
7.0.150.0120.00816.42
7.0.140.0220.00516.36
7.0.130.0140.00616.45
7.0.120.0080.01416.43
7.0.110.0140.00916.38
7.0.100.0140.00716.41
7.0.90.0090.01016.24
7.0.80.0160.00616.24
7.0.70.0110.00616.23
7.0.60.0180.00316.36
7.0.50.0160.00716.39
7.0.40.0140.00616.40
7.0.30.0170.00516.41
7.0.20.0190.00516.39
7.0.10.0150.00716.38
7.0.00.0130.00616.39
5.6.400.0130.00816.11
5.6.390.0150.00716.00
5.6.380.0140.00616.07
5.6.370.0120.00716.58
5.6.360.0130.00616.60
5.6.350.0080.01216.49
5.6.340.0170.00716.60
5.6.330.0130.00816.45
5.6.320.0130.00716.52
5.6.310.0150.01116.54
5.6.300.0140.00416.48
5.6.290.0110.00916.50
5.6.280.0180.00616.55
5.6.270.0130.00616.46
5.6.260.0140.00716.57
5.6.250.0110.00916.56
5.6.240.0100.00916.61
5.6.230.0110.00716.56
5.6.220.0140.00716.54
5.6.210.0150.00516.49
5.6.200.0120.00816.63
5.6.190.0140.00616.55
5.6.180.0140.01016.72
5.6.170.0080.01216.67
5.6.160.0120.01216.62
5.6.150.0120.01016.60
5.6.140.0100.00916.67
5.6.130.0150.00816.51
5.6.120.0160.00616.65
5.6.110.0160.00716.57
5.6.100.0190.00616.47
5.6.90.0180.00416.51
5.6.80.0120.01016.52
5.6.70.0160.00616.65
5.6.60.0100.01016.61
5.6.50.0090.01016.45
5.6.40.0170.00916.55
5.6.30.0100.01216.48
5.6.20.0120.00916.51
5.6.10.0140.00716.45
5.6.00.0150.00616.41

preferences:
28.7 ms | 403 KiB | 5 Q