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'), 'opcionais' => array( 'opcional' => 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.60.0100.01318.93
8.3.50.0180.00018.17
8.3.40.0090.01219.22
8.3.30.0110.00718.98
8.3.20.0070.01419.41
8.3.10.0090.00022.06
8.3.00.0040.00420.88
8.2.180.0110.00418.41
8.2.170.0180.00019.29
8.2.160.0110.00422.96
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00420.08
8.2.120.0040.00426.35
8.2.110.0060.00320.60
8.2.100.0110.00018.02
8.2.90.0050.00318.00
8.2.80.0040.00417.97
8.2.70.0000.00818.29
8.2.60.0040.00418.47
8.2.50.0000.00918.10
8.2.40.0040.00419.55
8.2.30.0040.00419.40
8.2.20.0000.00718.33
8.2.10.0000.00718.32
8.2.00.0030.00617.93
8.1.280.0160.00625.92
8.1.270.0000.00819.00
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00324.04
8.1.230.0110.00021.09
8.1.220.0060.00317.93
8.1.210.0000.00818.77
8.1.200.0000.01017.60
8.1.190.0060.00317.35
8.1.180.0000.00818.10
8.1.170.0050.00518.78
8.1.160.0000.00719.08
8.1.150.0040.00419.08
8.1.140.0040.00422.25
8.1.130.0040.00420.49
8.1.120.0000.00717.57
8.1.110.0040.00417.71
8.1.100.0000.00717.55
8.1.90.0000.00717.57
8.1.80.0030.00517.57
8.1.70.0090.00017.70
8.1.60.0060.00317.85
8.1.50.0060.00317.77
8.1.40.0080.00017.64
8.1.30.0030.00917.92
8.1.20.0000.00817.77
8.1.10.0080.00017.67
8.1.00.0040.00417.64
8.0.300.0030.00618.77
8.0.290.0060.00317.13
8.0.280.0050.00218.59
8.0.270.0030.00517.42
8.0.260.0030.00318.61
8.0.250.0000.00817.25
8.0.240.0070.00017.22
8.0.230.0080.00017.24
8.0.220.0030.00617.10
8.0.210.0040.00417.04
8.0.200.0030.00317.13
8.0.190.0000.00817.07
8.0.180.0080.00017.18
8.0.170.0030.00617.18
8.0.160.0000.00717.21
8.0.150.0000.00817.02
8.0.140.0000.00817.16
8.0.130.0000.00513.62
8.0.120.0040.00417.18
8.0.110.0000.00817.07
8.0.100.0000.00917.29
8.0.90.0070.00016.99
8.0.80.0090.00617.13
8.0.70.0040.00417.28
8.0.60.0000.00717.08
8.0.50.0000.00817.20
8.0.30.0110.00817.31
8.0.20.0090.00917.40
8.0.10.0040.00417.21
8.0.00.0110.00816.87
7.4.330.0030.00315.55
7.4.320.0080.00016.58
7.4.300.0000.00716.72
7.4.290.0030.00316.69
7.4.280.0070.00016.66
7.4.270.0000.00716.89
7.4.260.0000.00916.79
7.4.250.0020.00516.76
7.4.240.0040.00416.73
7.4.230.0000.00716.74
7.4.220.0030.00516.91
7.4.210.0080.00616.71
7.4.200.0080.00016.89
7.4.160.0100.00716.77
7.4.140.0110.00917.86
7.4.130.0150.00316.80
7.4.120.0120.00816.70
7.4.110.0110.00716.77
7.4.100.0140.00716.78
7.4.90.0100.01016.71
7.4.80.0120.00419.39
7.4.70.0140.00416.91
7.4.60.0060.00916.77
7.4.50.0070.00716.65
7.4.40.0110.00616.94
7.4.00.0090.00615.11
7.3.330.0020.00213.48
7.3.320.0030.00313.54
7.3.310.0000.00816.54
7.3.300.0030.00316.41
7.3.290.0070.00016.40
7.3.280.0060.00916.46
7.3.260.0110.00916.65
7.3.240.0100.01016.61
7.3.230.0160.00016.62
7.3.210.0110.00716.54
7.3.200.0130.00316.63
7.3.190.0120.00916.80
7.3.180.0110.00716.80
7.3.170.0030.01616.52
7.3.160.0080.00916.89
7.2.330.0080.00916.69
7.2.320.0060.01617.09
7.2.310.0040.01316.58
7.2.300.0080.00817.04
7.2.290.0030.01917.02
7.2.110.0580.01115.00
7.2.100.0820.00414.76
7.2.90.0700.01214.79
7.2.80.0680.00714.86
7.2.70.0530.01214.88
7.2.60.0720.01314.95
7.2.50.0560.01315.07
7.2.40.0770.00514.87
7.2.30.0630.00514.71
7.2.20.1130.01014.74
7.2.10.0720.00714.80
7.2.00.0680.00814.89
7.1.230.0630.00513.96
7.1.220.0850.00314.21
7.1.210.0780.00713.94
7.1.200.0610.00813.92
7.1.190.0560.00813.89
7.1.180.0580.00814.02
7.1.170.0630.00813.88
7.1.160.0500.01013.64
7.1.150.0660.00813.55
7.1.140.0940.00813.89
7.1.130.0480.00614.00
7.1.120.0680.00713.73
7.1.110.0680.00313.71
7.1.100.0550.00513.88
7.1.90.0480.00713.85
7.1.80.0640.00513.88
7.1.70.0690.01013.96
7.1.60.0730.01131.75
7.1.50.0620.00431.97
7.1.40.0740.00831.61
7.1.30.0680.01031.94
7.1.20.0410.01532.02
7.1.10.0700.00813.95
7.1.00.0620.00614.01
5.6.380.0030.01314.43

preferences:
64.33 ms | 400 KiB | 5 Q