3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xml_to_array($root) { $result = array(); if ($root->hasAttributes()) { $attrs = $root->attributes; foreach ($attrs as $attr) { $result['@attributes'][$attr->name] = $attr->value; } } if ($root->hasChildNodes()) { $children = $root->childNodes; if ($children->length == 1) { $child = $children->item(0); if ($child->nodeType == XML_TEXT_NODE) { $result['_value'] = $child->nodeValue; return count($result) == 1 ? $result['_value'] : $result; } } $groups = array(); foreach ($children as $child) { if (!isset($result[$child->nodeName])) { $result[$child->nodeName] = xml_to_array($child); } else { if (!isset($groups[$child->nodeName])) { $result[$child->nodeName] = array($result[$child->nodeName]); $groups[$child->nodeName] = 1; } $result[$child->nodeName][] = xml_to_array($child); } } } return $result; } $xml = "<Msg> <Txn>submitsms </Txn> <AccountID>123456789</AccountID> <Password>barfoo123</Password> <Message>test message</Message> <RateCode>1</RateCode> <Mobiles> <MobileNo>07123456701</MobileNo> </Mobiles> </Msg>"; $doc = new DOMDocument(); $doc->loadXML($xml); var_dump(xml_to_array($doc));

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.0090.00918.80
8.3.50.0110.00718.57
8.3.40.0100.00619.14
8.3.30.0080.00818.96
8.3.20.0040.00419.32
8.3.10.0080.00022.03
8.3.00.0040.00423.77
8.2.180.0160.00618.54
8.2.170.0000.01522.96
8.2.160.0070.00719.41
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00421.13
8.2.110.0060.00322.38
8.2.100.0110.00018.16
8.2.90.0030.00618.47
8.2.80.0090.00018.26
8.2.70.0030.00618.29
8.2.60.0080.00018.34
8.2.50.0030.00618.10
8.2.40.0040.00419.59
8.2.30.0030.00619.61
8.2.20.0030.00618.42
8.2.10.0000.00918.32
8.2.00.0080.00019.58
8.1.280.0070.00725.92
8.1.270.0050.00324.01
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00324.17
8.1.230.0080.00321.21
8.1.220.0040.00418.01
8.1.210.0000.01218.77
8.1.200.0100.00017.61
8.1.190.0050.00317.35
8.1.180.0050.00318.10
8.1.170.0050.00518.87
8.1.160.0000.00719.20
8.1.150.0070.00019.23
8.1.140.0080.00017.96
8.1.130.0000.00719.13
8.1.120.0000.00817.63
8.1.110.0000.00817.58
8.1.100.0050.00317.72
8.1.90.0040.00417.58
8.1.80.0000.00817.59
8.1.70.0020.00517.75
8.1.60.0030.00617.74
8.1.50.0080.00017.75
8.1.40.0040.00417.77
8.1.30.0050.00317.87
8.1.20.0000.00817.84
8.1.10.0030.00517.79
8.1.00.0000.00817.76
8.0.300.0040.00420.31
8.0.290.0040.00417.00
8.0.280.0050.00218.73
8.0.270.0070.00017.50
8.0.260.0030.00317.37
8.0.250.0070.00017.10
8.0.240.0030.00517.09
8.0.230.0070.00017.19
8.0.220.0000.00817.05
8.0.210.0040.00417.21
8.0.200.0040.00417.05
8.0.190.0000.00717.11
8.0.180.0000.00817.07
8.0.170.0030.00617.10
8.0.160.0000.00817.19
8.0.150.0000.00716.97
8.0.140.0000.00717.01
8.0.130.0030.00313.63
8.0.120.0030.00516.98
8.0.110.0000.00716.93
8.0.100.0070.00017.16
8.0.90.0040.00417.14
8.0.80.0060.01017.13
8.0.70.0040.00417.15
8.0.60.0030.00517.13
8.0.50.0070.00017.03
8.0.30.0080.01217.37
8.0.20.0170.00817.50
8.0.10.0080.00017.23
8.0.00.0100.00917.00
7.4.330.0020.00215.55
7.4.320.0000.00616.66
7.4.300.0030.00316.66
7.4.290.0040.00716.76
7.4.280.0040.00416.91
7.4.270.0040.00416.66
7.4.260.0000.00916.72
7.4.250.0040.00416.83
7.4.240.0070.00016.89
7.4.230.0000.00716.73
7.4.220.0000.00816.75
7.4.210.0060.00816.77
7.4.200.0000.00716.74
7.4.160.0110.00716.80
7.4.140.0160.01017.86
7.4.130.0100.01016.71
7.4.120.0120.00916.80
7.4.110.0100.00916.85
7.4.100.0100.00716.68
7.4.90.0090.00916.66
7.4.80.0090.00919.39
7.4.70.0100.00616.78
7.4.60.0030.01216.60
7.4.50.0030.01316.59
7.4.40.0120.01216.76
7.4.10.0070.01116.40
7.4.00.0070.01115.42
7.3.330.0030.00313.65
7.3.320.0000.00613.35
7.3.310.0080.00016.64
7.3.300.0070.00016.60
7.3.290.0030.00316.59
7.3.280.0030.01316.64
7.3.260.0090.00916.70
7.3.240.0110.00916.72
7.3.230.0070.01016.65
7.3.210.0090.01516.73
7.3.200.0130.00416.80
7.3.190.0110.00816.88
7.3.180.0180.00016.90
7.3.170.0090.00916.59
7.3.160.0140.00316.64
7.3.130.0070.01416.55
7.3.120.0070.01015.86
7.3.110.0070.01115.73
7.3.100.0130.00315.77
7.3.90.0030.01015.96
7.3.80.0050.00815.86
7.3.70.0030.01015.73
7.3.60.0080.00615.61
7.3.50.0090.00715.76
7.3.40.0040.01015.79
7.3.30.0020.01315.74
7.3.20.0020.01217.58
7.3.10.0000.01517.39
7.3.00.0060.00917.54
7.2.330.0160.00316.66
7.2.320.0060.01216.88
7.2.310.0110.01316.89
7.2.300.0090.01216.81
7.2.290.0100.01717.08
7.2.260.0100.01016.88
7.2.250.0110.00916.19
7.2.240.0070.01216.12
7.2.230.0110.00515.78
7.2.220.0070.00616.07
7.2.210.0110.00616.12
7.2.200.0100.00315.99
7.2.190.0050.01215.95
7.2.180.0060.01016.01
7.2.170.0030.00915.94
7.2.160.0070.00716.77
7.2.150.0030.01518.62
7.2.140.0090.00918.54
7.2.130.0060.01318.68
7.2.120.0060.01018.65
7.2.110.0000.01718.67
7.2.100.0030.01018.51
7.2.90.0060.00918.75
7.2.80.0060.00617.74
7.2.70.0420.00817.05
7.2.60.0370.01016.96
7.2.50.0290.01017.00
7.2.40.0490.01217.02
7.2.30.0540.01116.91
7.2.20.0410.01216.81
7.2.10.0380.00816.83
7.2.00.0450.00916.95
7.1.330.0070.01016.67
7.1.320.0000.01316.80
7.1.310.0080.00616.72
7.1.300.0050.00916.80
7.1.290.0040.01016.76
7.1.280.0030.01016.58
7.1.270.0020.01316.69
7.1.260.0040.00816.79
7.1.250.0070.01017.64
7.1.240.0130.00317.50
7.1.230.0030.01017.63
7.1.220.0070.01017.56
7.1.210.0030.00617.54
7.1.200.0070.00716.72
7.1.190.0000.01217.47
7.1.180.0040.00717.42
7.1.170.0370.00715.70
7.1.160.0500.01015.87
7.1.150.0450.01115.84
7.1.140.0370.00515.80
7.1.130.0410.00615.48
7.1.120.0350.01015.83
7.1.110.0300.01215.70
7.1.100.0310.00815.76
7.1.90.0410.00615.76
7.1.80.0610.00915.70
7.1.70.0380.01315.74
7.1.60.0450.00924.68
7.1.50.0680.00824.81
7.1.40.0540.01224.75
7.1.30.0550.01124.59
7.1.20.1030.01224.79
7.1.10.0660.00515.73
7.1.00.0280.01115.89
7.0.330.0100.00617.37
7.0.320.0000.01217.32
7.0.310.0070.00717.10
7.0.300.0080.00617.19
7.0.290.0040.01117.05
7.0.280.0000.01517.02
7.0.270.0100.00317.26
7.0.260.0000.01917.23
7.0.250.0030.01017.17
7.0.240.0080.00817.29
7.0.230.0100.00717.17
7.0.220.0000.01417.05
7.0.210.0040.01117.14
7.0.200.0040.00917.24
7.0.190.0030.01317.23
7.0.180.0060.00917.31
7.0.170.0110.00417.36
7.0.160.0060.00917.25
7.0.150.0110.00717.33
7.0.140.0040.00817.17
7.0.130.0140.00417.36
7.0.120.0030.00617.13
7.0.110.0070.00717.41
7.0.100.0030.01217.32
7.0.90.0060.00817.24
7.0.80.0040.00717.24
7.0.70.0040.01117.11
7.0.60.0060.00317.18
7.0.50.0030.00917.10
7.0.40.0040.01115.20
7.0.30.0090.00615.18
7.0.20.0030.00615.16
7.0.10.0110.00415.15
7.0.00.0110.00015.11
5.6.400.0040.00816.07
5.6.390.0030.01315.97
5.6.380.0120.00316.27
5.6.370.0100.00316.45
5.6.360.0000.01016.19
5.6.350.0030.00915.98
5.6.340.0000.01016.26
5.6.330.0070.01416.29
5.6.320.0060.00616.02
5.6.310.0060.01016.21
5.6.300.0030.01416.32
5.6.290.0120.00316.26
5.6.280.0070.01016.00
5.6.270.0060.00916.48
5.6.260.0040.00716.33
5.6.250.0030.01016.20
5.6.240.0080.00416.11
5.6.230.0000.01316.17
5.6.220.0100.00716.11
5.6.210.0040.00816.34
5.6.200.0030.00716.05
5.6.190.0090.00616.41
5.6.180.0070.00316.27
5.6.170.0060.00616.25
5.6.160.0040.01116.23
5.6.150.0060.00916.20
5.6.140.0100.00616.39
5.6.130.0070.00716.04
5.6.120.0040.01216.15
5.6.110.0070.00716.38
5.6.100.0000.01116.14
5.6.90.0000.00916.11
5.6.80.0040.00816.09
5.6.70.0130.00315.97
5.6.60.0030.01016.18
5.6.50.0030.01016.21
5.6.40.0090.00615.99
5.6.30.0100.00016.20
5.6.20.0030.01016.27
5.6.10.0030.01016.21
5.6.00.0060.00616.16

preferences:
60.25 ms | 401 KiB | 5 Q