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 ); continue; } if (is_numeric($key)) { $key = $name; } if (is_array($value)) { $areAllInt = true; foreach(array_keys($value) as $k) { if (!is_int($k)) { $areAllInt = false; break; } } if ($areAllInt) { array_to_xml_aux($value, $parent, $key); } else { $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.60.0030.01218.66
8.3.50.0100.01018.53
8.3.40.0060.00918.90
8.3.30.0100.00618.92
8.3.20.0000.00721.98
8.3.10.0000.00823.65
8.3.00.0080.00019.81
8.2.180.0160.00018.79
8.2.170.0120.00322.96
8.2.160.0130.00619.38
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0070.00319.44
8.2.120.0000.00826.35
8.2.110.0100.00019.44
8.2.100.0080.00418.16
8.2.90.0000.00819.22
8.2.80.0000.01018.16
8.2.70.0000.00917.88
8.2.60.0060.00318.15
8.2.50.0040.00418.07
8.2.40.0000.00820.20
8.2.30.0070.00018.22
8.2.20.0040.00418.18
8.2.10.0050.00318.21
8.2.00.0040.00418.23
8.1.280.0060.00925.92
8.1.270.0080.00024.04
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0040.00422.32
8.1.230.0110.00017.77
8.1.220.0060.00317.91
8.1.210.0000.00818.77
8.1.200.0060.00317.47
8.1.190.0040.00417.76
8.1.180.0030.00618.10
8.1.170.0040.00418.54
8.1.160.0000.00819.08
8.1.150.0000.00719.09
8.1.140.0000.00717.81
8.1.130.0000.00719.11
8.1.120.0040.00417.69
8.1.110.0030.00517.54
8.1.100.0000.00717.68
8.1.90.0040.00417.72
8.1.80.0040.00417.54
8.1.70.0030.00317.67
8.1.60.0030.00617.77
8.1.50.0050.00317.75
8.1.40.0040.00417.58
8.1.30.0000.00817.86
8.1.20.0030.00617.70
8.1.10.0090.00017.71
8.1.00.0000.00817.66
8.0.300.0060.00318.77
8.0.290.0080.00017.30
8.0.280.0000.00718.65
8.0.270.0030.00517.46
8.0.260.0060.00017.37
8.0.250.0070.00017.24
8.0.240.0070.00017.15
8.0.230.0030.00317.22
8.0.220.0040.00417.17
8.0.210.0030.00417.19
8.0.200.0000.01116.93
8.0.190.0040.00417.14
8.0.180.0070.00017.19
8.0.170.0030.00617.17
8.0.160.0000.00717.17
8.0.150.0040.00417.09
8.0.140.0070.00017.04
8.0.130.0030.00313.59
8.0.120.0000.00717.05
8.0.110.0000.00717.08
8.0.100.0040.00417.26
8.0.90.0000.00716.87
8.0.80.0090.00617.12
8.0.70.0070.00017.19
8.0.60.0070.00017.18
8.0.50.0070.00017.18
8.0.30.0120.00817.30
8.0.20.0100.01017.40
8.0.10.0000.00717.38
8.0.00.0090.01017.03
7.4.330.0040.00015.55
7.4.320.0030.00316.75
7.4.300.0030.00316.60
7.4.290.0030.00316.66
7.4.280.0090.00016.67
7.4.270.0030.00416.69
7.4.260.0000.00716.86
7.4.250.0000.00816.60
7.4.240.0050.00216.79
7.4.230.0030.00516.90
7.4.220.0050.00316.56
7.4.210.0130.00116.81
7.4.200.0040.00416.87
7.4.160.0110.00516.70
7.4.140.0100.01017.86
7.4.130.0050.01316.68
7.4.120.0120.00716.75
7.4.110.0120.00816.64
7.4.100.0080.01416.66
7.4.90.0100.00716.76
7.4.80.0110.00917.60
7.4.70.0070.01116.71
7.4.60.0090.01116.70
7.4.50.0090.00916.68
7.4.40.0060.01216.47
7.4.30.0110.00816.54
7.4.20.0090.01216.67
7.4.10.0130.00816.73
7.4.00.0090.00916.19
7.3.330.0050.00416.25
7.3.320.0000.00613.53
7.3.310.0000.00816.42
7.3.300.0000.00716.45
7.3.290.0030.00316.49
7.3.280.0070.01216.54
7.3.260.0050.01416.58
7.3.250.0170.00016.62
7.3.240.0100.00716.63
7.3.230.0100.01016.58
7.3.220.0050.01416.54
7.3.210.0070.01216.63
7.3.200.0090.01016.52
7.3.190.0090.00816.54
7.3.180.0100.00916.59
7.3.170.0110.00916.65
7.3.160.0130.00616.69
7.3.150.0070.01016.62
7.3.140.0110.01116.51
7.3.130.0140.01016.53
7.3.120.0080.01316.53
7.3.110.0110.01016.70
7.3.100.0130.01016.54
7.3.90.0130.00716.64
7.3.80.0150.00716.73
7.3.70.0060.01216.56
7.3.60.0130.00616.09
7.3.50.0080.00916.03
7.3.40.0110.00916.05
7.3.30.0100.00916.03
7.3.20.0290.01016.64
7.3.10.0130.00616.68
7.3.00.0110.01016.62
7.2.340.0070.01516.78
7.2.330.0090.01116.84
7.2.320.0130.00716.83
7.2.310.0130.00617.02
7.2.300.0130.01016.92
7.2.290.0050.01516.86
7.2.280.0050.01616.80
7.2.270.0150.00916.81
7.2.260.0100.01116.95
7.2.250.0120.00916.66
7.2.240.0120.01216.56
7.2.230.0140.01116.93
7.2.220.0120.00816.87
7.2.210.0160.00616.84
7.2.200.0070.01416.94
7.2.190.0120.00816.28
7.2.180.0130.00516.24
7.2.170.0110.00816.29
7.2.160.0120.00916.28
7.2.150.0140.00716.94
7.2.140.0150.00716.93
7.2.130.0090.01416.97
7.2.120.0100.00816.84
7.2.110.0100.00916.75
7.2.100.0110.00716.84
7.2.90.0090.01316.89
7.2.80.0110.00716.84
7.2.70.0220.00716.93
7.2.60.0100.00816.86
7.2.50.0120.00716.72
7.2.40.1280.01017.25
7.2.30.0900.01217.20
7.2.20.1160.01217.17
7.2.10.1230.00917.18
7.2.00.1120.00917.24
7.1.330.0220.01015.77
7.1.320.0240.00715.74
7.1.310.0210.01115.78
7.1.300.0200.00515.87
7.1.290.0170.00915.88
7.1.280.0170.01015.86
7.1.270.0190.00815.83
7.1.260.0160.01115.78
7.1.250.0180.00815.78
7.1.240.0200.00715.68
7.1.230.0150.01115.77
7.1.220.0180.01015.79
7.1.210.0200.01215.72
7.1.200.0150.00915.76
7.1.190.0210.00915.82
7.1.180.0210.00915.72
7.1.170.0210.00615.76
7.1.160.1160.00816.00
7.1.150.1210.01016.04
7.1.140.1120.00716.14
7.1.130.1260.00916.03
7.1.120.0970.01116.04
7.1.110.0850.00915.90
7.1.100.1050.01115.81
7.1.90.1620.00715.97
7.1.80.1470.00915.95
7.1.70.1730.00815.67
7.1.60.1510.00820.19
7.1.50.2430.00820.04
7.1.40.2040.01220.01
7.1.30.2090.01620.01
7.1.20.2420.01120.09
7.1.10.2190.00915.20
7.1.00.1310.01015.07
7.0.330.0350.00515.44
7.0.320.0240.00415.43
7.0.310.0190.01115.50
7.0.300.0170.00715.46
7.0.290.0220.00615.45
7.0.280.0170.00915.46
7.0.270.0200.00915.35
7.0.260.0170.01215.45
7.0.250.0250.00915.48
7.0.240.0200.00815.46
7.0.230.0200.00815.47
7.0.220.0210.01115.59
7.0.210.0290.00915.55
7.0.200.0220.00815.51
7.0.190.0220.00915.43
7.0.180.0200.00915.48
7.0.170.0230.00715.41
7.0.160.0170.00915.46
7.0.150.0190.01014.95
7.0.140.0310.01014.73
7.0.130.0170.01114.80
7.0.120.0200.01114.76
7.0.110.0180.01214.87
7.0.100.0190.00914.83
7.0.90.0250.00614.83
7.0.80.0180.00914.85
7.0.70.0240.00314.97
7.0.60.0230.00914.90
7.0.50.0190.00714.92
7.0.40.0210.00514.89
7.0.30.0190.00914.87
7.0.20.0190.01214.84
7.0.10.0180.01114.79
7.0.00.0200.00714.96
5.6.400.0160.01415.63
5.6.390.0200.01015.84
5.6.380.0230.00915.55
5.6.370.0280.00915.61
5.6.360.0190.00915.60
5.6.350.0190.01215.58
5.6.340.0150.01215.72
5.6.330.0220.00915.72
5.6.320.0220.00915.74
5.6.310.0220.00815.80
5.6.300.0170.03317.06
5.6.290.0200.02117.01
5.6.280.0160.02816.94
5.6.270.0190.02417.01
5.6.260.0210.02316.98
5.6.250.0150.02816.96
5.6.240.0210.02017.10
5.6.230.0220.02117.05
5.6.220.0170.02716.96
5.6.210.0230.01916.99
5.6.200.0170.02917.07
5.6.190.0180.02417.09
5.6.180.0200.02516.86
5.6.170.0160.02616.77
5.6.160.0180.02916.93
5.6.150.0150.03016.90
5.6.140.0240.02517.03
5.6.130.0180.02517.00
5.6.120.0170.02616.99
5.6.110.0160.02517.02
5.6.100.0230.02816.92
5.6.90.0220.02116.99
5.6.80.0130.02816.65
5.6.70.0190.02116.66
5.6.60.0190.02516.70
5.6.50.0150.02516.78
5.6.40.0210.02216.68
5.6.30.0170.02816.73
5.6.20.0170.02816.78
5.6.10.0140.02316.70
5.6.00.0170.02016.70

preferences:
61.4 ms | 401 KiB | 5 Q