3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( 'id' => 1, 'name' => 'Jacopo', 'male' => true, 'birthday' => new DateTime('1988-07-26'), 'hobbies' => array( 'Programming', 'TV Shows', 'Skiing' ) ); $rootXMLElement = '<data />'; $xml = new SimpleXMLElementExtended('<?xml version="1.0"?>' . $rootXMLElement); arrayToXML($data, $xml); echo $xml->asXML(); // http://coffeerings.posterous.com/php-simplexml-and-cdata class SimpleXMLElementExtended extends SimpleXMLElement { public function addCDATA($text) { $node = dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($text)); } public function getParentNode() { return current($this->xpath('parent::*')); } } function arrayToXML($data, &$xml) { foreach ($data as $key => $value) { if (is_numeric($key)) { $key = 'item'; } if (is_array($value)) { if (!is_numeric($key)) { $node = $xml->addChild($key); arrayToXML($value, $node); } else { // $currentNodeName = $xml->getName(); // $currentNodeNameSingular = @Inflector::singularize($currentNodeName); // if ( $currentNodeName != 'data' // && $currentNodeName != $currentNodeNameSingular // ) { // $key = $currentNodeNameSingular; // } else { // $key = 'item'; // } $node = $xml->addChild($key); arrayToXML($value, $node); } } else { $xml->addChild($key, $value); /* if (strpos($value, '<') === false) { $xml->addChild($key, $value); } else { $xml->addChild($key)->addCDATA($value); } */ } } }

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.0070.01018.78
8.3.50.0090.00722.17
8.3.40.0040.01119.21
8.3.30.0000.01819.39
8.3.20.0080.00020.29
8.3.10.0080.00023.86
8.3.00.0090.00020.90
8.2.180.0190.00318.91
8.2.170.0110.00422.96
8.2.160.0100.00320.70
8.2.150.0060.00324.18
8.2.140.0030.00624.66
8.2.130.0150.00326.16
8.2.120.0080.00019.86
8.2.110.0000.00920.60
8.2.100.0040.00718.28
8.2.90.0040.00419.51
8.2.80.0080.00018.13
8.2.70.0060.00318.00
8.2.60.0050.00318.29
8.2.50.0030.00618.07
8.2.40.0040.00420.32
8.2.30.0040.00418.61
8.2.20.0030.00518.14
8.2.10.0000.00718.39
8.2.00.0090.00018.28
8.1.280.0150.00325.92
8.1.270.0080.00022.43
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00624.04
8.1.230.0090.00322.75
8.1.220.0000.00818.16
8.1.210.0040.00418.77
8.1.200.0040.00417.85
8.1.190.0000.00817.86
8.1.180.0040.00418.10
8.1.170.0050.00319.02
8.1.160.0060.00322.27
8.1.150.0030.00718.97
8.1.140.0060.00318.00
8.1.130.0020.00519.80
8.1.120.0070.00017.93
8.1.110.0070.00017.84
8.1.100.0040.00417.79
8.1.90.0040.00417.79
8.1.80.0000.00817.87
8.1.70.0040.00417.81
8.1.60.0030.00517.97
8.1.50.0060.00317.84
8.1.40.0080.00417.80
8.1.30.0040.00417.92
8.1.20.0000.00818.08
8.1.10.0000.00817.82
8.1.00.0000.00817.87
8.0.300.0000.00718.77
8.0.290.0040.00417.25
8.0.280.0050.00218.74
8.0.270.0000.00717.68
8.0.260.0000.00717.57
8.0.250.0030.00317.43
8.0.240.0100.00017.36
8.0.230.0030.00317.49
8.0.220.0000.00717.39
8.0.210.0040.00417.33
8.0.200.0030.00317.45
8.0.190.0000.00717.41
8.0.180.0030.00517.35
8.0.170.0000.00817.38
8.0.160.0000.00817.29
8.0.150.0030.00717.48
8.0.140.0080.00017.27
8.0.130.0030.00313.78
8.0.120.0000.00917.39
8.0.110.0080.00017.47
8.0.100.0040.00417.51
8.0.90.0050.00217.46
8.0.80.0070.00817.41
8.0.70.0000.00717.43
8.0.60.0050.00217.50
8.0.50.0070.00017.40
8.0.30.0110.00817.57
8.0.20.0110.00817.60
8.0.10.0040.00417.38
8.0.00.0090.01217.27
7.4.330.0060.00015.27
7.4.320.0030.00317.00
7.4.300.0060.00016.98
7.4.290.0040.00416.92
7.4.280.0080.00016.84
7.4.270.0030.00316.90
7.4.260.0040.00716.92
7.4.250.0040.00416.88
7.4.240.0040.00317.00
7.4.230.0040.00417.07
7.4.220.0110.00616.92
7.4.210.0040.01216.79
7.4.200.0050.00317.10
7.4.160.0060.01016.75
7.4.150.0130.00617.40
7.4.140.0110.01017.86
7.4.130.0080.01117.23
7.4.120.0150.00317.00
7.4.110.0100.01316.79
7.4.100.0040.01416.79
7.4.90.0060.01217.13
7.4.80.0090.01519.39
7.4.70.0080.00816.97
7.4.60.0030.01417.12
7.4.50.0030.00317.01
7.4.40.0130.00316.96
7.4.30.0030.01416.94
7.4.00.0080.00815.30
7.3.330.0030.00313.56
7.3.320.0060.00013.61
7.3.310.0030.00316.81
7.3.300.0030.00316.82
7.3.290.0110.00316.72
7.3.280.0100.00616.79
7.3.270.0140.00617.40
7.3.260.0040.01416.75
7.3.250.0100.01217.06
7.3.240.0060.01217.02
7.3.230.0050.01317.01
7.3.210.0030.01416.87
7.3.200.0110.00719.39
7.3.190.0070.01617.10
7.3.180.0160.00017.00
7.3.170.0190.00316.83
7.3.160.0120.00416.91
7.3.120.0060.01015.05
7.3.00.0110.00317.03
7.2.330.0140.00617.28
7.2.320.0160.00317.30
7.2.310.0070.01117.27
7.2.300.0070.01017.14
7.2.290.0080.01617.09
7.2.130.0040.01117.27
7.2.120.0080.00417.23
7.2.110.0000.01217.22
7.2.100.0070.00717.18
7.2.90.0080.00817.25
7.2.80.0060.00617.46
7.2.70.0030.00717.24
7.2.60.0060.00317.05
7.2.50.0100.00617.38
7.2.40.0000.01017.13
7.2.30.0070.00317.08
7.2.20.0000.01217.25
7.2.10.0120.00317.10
7.2.00.0060.00618.31
7.1.250.0070.00315.89
7.1.240.0060.00315.96
7.1.230.0060.00616.04
7.1.220.0030.00716.09
7.1.210.0060.01015.95
7.1.200.0040.00816.07
7.1.190.0160.00315.92
7.1.180.0100.00716.11
7.1.170.0040.00415.78
7.1.160.0150.00315.90
7.1.150.0040.00715.95
7.1.140.0050.00316.07
7.1.130.0070.00716.07
7.1.120.0060.00615.94
7.1.110.0040.00815.88
7.1.100.0100.00517.18
7.1.90.0100.00316.06
7.1.80.0000.00915.85
7.1.70.0050.00616.77
7.1.60.0070.01017.80
7.1.50.0110.01016.56
7.1.40.0040.00816.10
7.1.30.0030.01015.79
7.1.20.0070.00715.93
7.1.10.0090.00615.84
7.1.00.0020.04219.23
7.0.330.0030.01015.63
7.0.320.0050.00515.57
7.0.310.0080.00315.63
7.0.300.0110.00015.58
7.0.290.0090.00315.78
7.0.280.0070.00315.56
7.0.270.0040.00415.44
7.0.260.0070.00015.47
7.0.250.0030.01015.64
7.0.240.0000.01315.74
7.0.230.0100.00315.74
7.0.220.0030.01015.62
7.0.210.0120.00615.61
7.0.200.0040.00616.39
7.0.190.0030.01015.81
7.0.180.0000.01015.43
7.0.170.0000.01315.57
7.0.160.0080.00415.45
7.0.150.0100.00715.83
7.0.140.0080.03318.79
7.0.130.0070.00715.74
7.0.120.0070.00715.84
7.0.110.0070.00715.69
7.0.100.0060.00615.58
7.0.90.0000.01015.62
7.0.80.0050.00515.93
7.0.70.0050.01718.74
7.0.60.0030.02018.72
7.0.50.0070.04218.96
7.0.40.0050.04216.85
7.0.30.0090.04516.94
7.0.20.0100.03716.89
7.0.10.0060.03616.95
7.0.00.0080.04216.86
5.6.380.0100.00314.78
5.6.370.0090.00314.65
5.6.360.0030.00614.66
5.6.350.0040.00814.75
5.6.340.0030.00614.23
5.6.330.0070.00414.44
5.6.320.0030.00514.57
5.6.310.0060.00614.47
5.6.300.0100.00314.59
5.6.290.0040.00814.51
5.6.280.0050.04018.01
5.6.270.0040.00814.71
5.6.260.0100.00314.94
5.6.250.0000.01014.83
5.6.240.0070.00314.54
5.6.230.0070.00314.53
5.6.220.0030.02517.75
5.6.210.0040.03017.54
5.6.200.0030.04517.76
5.6.190.0040.04217.90
5.6.180.0030.03317.80
5.6.170.0070.04017.90
5.6.160.0070.03417.98
5.6.150.0070.04517.83
5.6.140.0050.04718.02
5.6.130.0050.04317.85
5.6.120.0020.05217.79
5.6.110.0080.04317.81
5.6.100.0050.04517.77
5.6.90.0070.04217.86
5.6.80.0020.02517.48
5.6.70.0050.04017.74
5.6.60.0070.04217.49
5.6.50.0020.04817.65
5.6.40.0080.04217.48
5.6.30.0030.04317.48
5.6.20.0030.04217.56
5.6.10.0060.04417.45
5.6.00.0070.03817.59
5.5.380.0080.00011.52
5.5.370.0070.00411.31
5.5.360.0030.02616.12
5.5.350.0030.01815.98
5.5.340.0020.02816.21
5.5.330.0060.04416.17
5.5.320.0020.04216.18
5.5.310.0070.03516.12
5.5.300.0050.04016.19
5.5.290.0040.04816.12
5.5.280.0030.04916.15
5.5.270.0030.04816.05
5.5.260.0040.02716.04
5.5.250.0070.02716.10
5.5.240.0050.02615.83
5.5.230.0050.04515.75
5.5.220.0040.04515.81
5.5.210.0030.04315.78
5.5.200.0040.04315.79
5.5.190.0050.04115.70
5.5.180.0070.04615.71
5.5.170.0000.01111.38
5.5.160.0060.03915.84
5.5.150.0080.03715.68
5.5.140.0040.04315.72
5.5.130.0050.04015.59
5.5.120.0070.04215.79
5.5.110.0040.04415.88
5.5.100.0080.04015.93
5.5.90.0020.04315.68
5.5.80.0040.03515.76
5.5.70.0050.03415.87
5.5.60.0070.04215.69
5.5.50.0030.04515.73
5.5.40.0030.04515.63
5.5.30.0000.04615.67
5.5.20.0000.04015.69
5.5.10.0050.04115.66
5.5.00.0020.04215.53
5.4.450.0100.04215.29
5.4.440.0080.04415.30
5.4.430.0070.04215.31
5.4.420.0050.03315.35
5.4.410.0070.03915.39
5.4.400.0090.02815.27
5.4.390.0020.02715.29
5.4.380.0050.03615.12
5.4.370.0020.04715.18
5.4.360.0090.03915.06
5.4.350.0000.04015.19
5.4.340.0050.03115.27
5.4.330.0060.00611.29
5.4.320.0070.03015.21
5.4.310.0040.03915.09
5.4.300.0050.04315.14
5.4.290.0090.03415.05
5.4.280.0070.04015.25
5.4.270.0070.04015.26
5.4.260.0030.04215.13
5.4.250.0030.04015.13
5.4.240.0030.04215.29
5.4.230.0030.03214.99
5.4.220.0060.03915.18
5.4.210.0080.03115.18
5.4.200.0040.04215.24
5.4.190.0040.04115.22
5.4.180.0030.03815.21
5.4.170.0050.03715.10
5.4.160.0070.03115.15
5.4.150.0020.04515.22
5.4.140.0070.03913.95
5.4.130.0070.03713.83
5.4.120.0050.03714.07
5.4.110.0070.03813.94
5.4.100.0020.03313.72
5.4.90.0030.02714.10
5.4.80.0050.02514.13
5.4.70.0030.03813.89
5.4.60.0060.03613.83
5.4.50.0070.03713.99
5.4.40.0080.03513.84
5.4.30.0060.03813.91
5.4.20.0080.03813.91
5.4.10.0020.04214.03
5.4.00.0030.03513.70
5.3.290.0030.04012.86
5.3.280.0050.03412.92
5.3.270.0040.04412.91
5.3.260.0070.03312.88
5.3.250.0080.03712.85
5.3.240.0000.04212.85
5.3.230.0040.03412.70
5.3.220.0050.03512.76
5.3.210.0050.03912.75
5.3.200.0020.03512.86
5.3.190.0040.03412.70
5.3.180.0040.04312.88
5.3.170.0030.04312.90
5.3.160.0030.04412.93
5.3.150.0070.03212.85
5.3.140.0040.04112.88
5.3.130.0020.04212.87
5.3.120.0060.04212.88
5.3.110.0080.04512.72
5.3.100.0010.04112.52
5.3.90.0050.03512.57
5.3.80.0050.03512.53
5.3.70.0040.03912.50
5.3.60.0080.03212.52
5.3.50.0050.03812.44
5.3.40.0020.04312.52
5.3.30.0040.04312.44
5.3.20.0090.03412.38
5.3.10.0030.03112.33
5.3.00.0060.04112.21
5.2.170.0060.02410.61
5.2.160.0090.02810.66
5.2.150.0050.03110.65
5.2.140.0070.03210.66
5.2.130.0050.02310.59
5.2.120.0070.03110.64
5.2.110.0060.03110.65
5.2.100.0020.03410.65
5.2.90.0050.03010.60
5.2.80.0080.03110.56
5.2.70.0030.03210.64
5.2.60.0000.03410.56
5.2.50.0080.03110.47
5.2.40.0030.03510.55
5.2.30.0030.02410.46
5.2.20.0090.03010.50
5.2.10.0060.02810.48
5.2.00.0040.03110.41
5.1.60.0040.0239.98
5.1.50.0070.0239.93
5.1.40.0030.0289.98
5.1.30.0020.03310.16
5.1.20.0020.03010.23
5.1.10.0030.02310.05
5.1.00.0050.01810.05
5.0.50.0040.0219.47
5.0.40.0060.0239.47
5.0.30.0020.0349.47
5.0.20.0030.0239.47
5.0.10.0020.0229.47
5.0.00.0000.0379.47
4.4.90.0030.0159.47
4.4.80.0030.0179.47
4.4.70.0040.0169.47
4.4.60.0020.0209.47
4.4.50.0030.0169.47
4.4.40.0000.0179.47
4.4.30.0010.0169.47
4.4.20.0000.0209.47
4.4.10.0020.0189.47
4.4.00.0000.0329.47
4.3.110.0000.0219.47
4.3.100.0020.0219.47
4.3.90.0030.0189.47
4.3.80.0020.0259.47
4.3.70.0030.0179.47
4.3.60.0000.0209.47
4.3.50.0020.0209.47
4.3.40.0020.0279.47
4.3.30.0020.0189.47
4.3.20.0020.0209.47
4.3.10.0030.0179.47
4.3.00.0020.0159.47

preferences:
43.37 ms | 401 KiB | 5 Q