3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XmlToArray { public function __construct() {} function xml2array($xml) { if (is_string($xml)) { $dom = new \DOMDocument; $v = $dom->loadXml($xml); if(!$v) {return false;} } return $this->_process($dom); } function _process($node) { $occurance = array(); $result = ""; if(isset($node->childNodes)) { foreach($node->childNodes as $child) { $occurance[$child->nodeName] = isset($occurance[$child->nodeName]) ? $occurance[$child->nodeName] + 1 : 1; } } if($node->nodeType == XML_TEXT_NODE) { $result = html_entity_decode(htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), ENT_COMPAT,'ISO-8859-15'); } else if($node->nodeType == XML_CDATA_SECTION_NODE){ $result = $node->nodeValue; } else { if($node->hasChildNodes()){ $children = $node->childNodes; for($i=0; $i<$children->length; $i++) { $child = $children->item($i); if ($child->nodeName == '#text' || $child->nodeName == '#cdata-section') { $text = $this->_process($child); if (trim($text) != '') { $result['#data'] = $this->_process($child); } } else { $result[$child->nodeName][] = $this->_process($child); } } } if($node->hasAttributes()) { $attributes = $node->attributes; if(!is_null($attributes)) { foreach ($attributes as $key => $attr) { $result["@".$attr->name] = $attr->value; } } } } return $result; } }

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.0000.01916.63
8.3.50.0160.00521.93
8.3.40.0000.01518.50
8.3.30.0180.00019.07
8.3.20.0040.00420.33
8.3.10.0040.00421.77
8.3.00.0090.00019.13
8.2.180.0160.00618.42
8.2.170.0120.00622.96
8.2.160.0070.00720.43
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0060.00919.23
8.2.110.0060.00318.96
8.2.100.0030.00917.63
8.2.90.0000.00918.92
8.2.80.0050.00317.97
8.2.70.0070.00617.38
8.2.60.0030.00617.80
8.2.50.0040.00418.07
8.2.40.0050.00218.03
8.2.30.0030.00618.07
8.2.20.0030.00617.53
8.2.10.0040.00417.81
8.2.00.0000.00817.61
8.1.280.0110.00725.92
8.1.270.0060.00318.70
8.1.260.0040.00426.35
8.1.250.0020.00528.09
8.1.240.0090.00023.93
8.1.230.0000.01117.54
8.1.220.0040.00417.74
8.1.210.0050.00518.77
8.1.200.0040.00417.10
8.1.190.0000.00817.23
8.1.180.0080.00018.10
8.1.170.0040.00418.56
8.1.160.0040.00421.89
8.1.150.0040.00418.80
8.1.140.0000.00817.41
8.1.130.0030.00517.79
8.1.120.0050.00217.41
8.1.110.0000.00817.31
8.1.100.0040.00417.32
8.1.90.0000.00817.32
8.1.80.0050.00217.41
8.1.70.0000.00717.34
8.1.60.0000.00817.38
8.1.50.0030.00617.48
8.1.40.0090.00017.42
8.1.30.0050.00317.54
8.1.20.0000.00817.53
8.1.10.0000.00817.27
8.1.00.0080.00417.20
8.0.300.0070.00018.77
8.0.290.0040.00416.63
8.0.280.0030.00518.27
8.0.270.0030.00317.05
8.0.260.0030.00318.27
8.0.250.0000.00716.88
8.0.240.0040.00416.84
8.0.230.0040.00416.88
8.0.220.0030.00316.73
8.0.210.0030.00316.84
8.0.200.0000.00716.72
8.0.190.0080.00316.91
8.0.180.0040.00416.85
8.0.170.0040.00416.71
8.0.160.0060.00316.77
8.0.150.0080.00016.76
8.0.140.0000.00816.80
8.0.130.0060.00013.18
8.0.120.0040.00416.66
8.0.110.0040.00416.86
8.0.100.0000.00716.62
8.0.90.0040.00416.82
8.0.80.0090.01316.75
8.0.70.0040.00416.68
8.0.60.0050.00316.81
8.0.50.0040.00416.66
8.0.30.0140.00817.06
8.0.20.0110.01117.40
8.0.10.0040.00416.82
8.0.00.0090.01016.48
7.4.330.0000.00715.03
7.4.320.0030.00316.42
7.4.300.0030.00316.39
7.4.290.0040.00416.48
7.4.280.0000.00816.32
7.4.270.0060.00316.40
7.4.260.0030.00316.32
7.4.250.0000.00816.39
7.4.240.0050.00216.51
7.4.230.0000.00716.30
7.4.220.0030.01916.50
7.4.210.0070.00716.46
7.4.200.0040.00416.26
7.4.160.0150.00016.29
7.4.150.0150.00617.40
7.4.140.0120.00717.86
7.4.130.0080.01316.36
7.4.120.0070.01216.41
7.4.110.0130.00916.54
7.4.100.0150.00316.36
7.4.90.0120.00616.61
7.4.80.0180.00019.39
7.4.70.0030.01716.28
7.4.60.0100.01116.48
7.4.50.0050.00316.33
7.4.40.0200.00316.52
7.4.30.0060.01116.55
7.4.00.0130.00314.55
7.3.330.0050.00013.21
7.3.320.0090.00413.21
7.3.310.0030.00316.08
7.3.300.0000.00616.22
7.3.290.0080.00616.23
7.3.280.0050.01116.21
7.3.270.0120.00617.40
7.3.260.0040.01316.26
7.3.250.0070.01016.36
7.3.240.0100.00716.57
7.3.230.0100.01016.39
7.3.210.0130.00316.23
7.3.200.0040.01119.39
7.3.190.0090.00616.30
7.3.180.0090.00616.20
7.3.170.0070.01016.37
7.3.160.0070.01016.23
7.2.330.0130.00616.30
7.2.320.0030.01316.20
7.2.310.0130.00416.43
7.2.300.0030.01816.49
7.2.290.0130.00316.56
7.2.00.0070.00419.27
7.1.100.0000.01217.97
7.1.70.0000.00816.93
7.1.60.0110.00719.50
7.1.50.0000.02216.85
7.1.00.0030.07722.32
7.0.200.0730.00714.74
7.0.140.0030.05022.08
7.0.60.0100.08320.04
7.0.50.0100.08017.92
7.0.40.0030.04320.23
7.0.30.0330.08320.16
7.0.20.0330.05720.26
7.0.10.0400.05720.06
7.0.00.0130.08020.14
5.6.280.0100.06721.12
5.6.210.0100.03720.73
5.6.200.0100.03718.26
5.6.190.0070.04020.38
5.6.180.0130.08320.53
5.6.170.0330.06020.55
5.6.160.0070.06020.45
5.6.150.0030.05018.14
5.6.140.0130.05318.18
5.6.130.0170.03018.24
5.6.120.0100.04021.01
5.6.110.0170.06721.13
5.6.100.0000.05021.01
5.6.90.0030.08721.04
5.6.80.0100.03720.39
5.6.70.2770.03720.29
5.5.350.0230.04320.35
5.5.340.0030.04017.96
5.5.330.0030.04320.34
5.5.320.0130.07320.26
5.5.310.0100.05320.26
5.5.300.0000.04317.95
5.5.290.0100.06017.98
5.5.280.0170.06720.79
5.5.270.0100.04320.70
5.5.260.0000.08720.99
5.5.250.0130.08020.71
5.5.240.0130.07320.13
5.4.450.0700.06019.72
5.4.440.1070.05019.62
5.4.430.0370.06319.29
5.4.420.0900.05319.56
5.4.410.0100.05718.86
5.4.400.1000.05018.63
5.4.390.0800.05318.61
5.4.380.0870.07018.60
5.4.370.0930.05318.49
5.4.360.0930.06018.65
5.4.350.0730.06318.84
5.4.340.1000.05318.63
5.4.320.0870.06318.78
5.4.310.1030.05318.78
5.4.300.1130.06718.75
5.4.290.0970.06318.75
5.4.280.1130.05318.73
5.4.270.1000.04718.54
5.4.260.0730.06318.75
5.4.250.0870.05718.85
5.4.240.1000.07018.79
5.4.230.1030.07318.79
5.4.220.0900.07018.47
5.4.210.0530.06018.77
5.4.200.0600.06016.55
5.4.190.0800.07318.58
5.4.180.0930.05718.45
5.4.170.0930.07318.41
5.4.160.0930.06318.81
5.4.150.1030.07318.73
5.4.140.0770.05316.20
5.4.130.3630.05016.23
5.4.120.0770.05316.25
5.4.110.2230.05016.31
5.4.100.1070.05716.46
5.4.90.0830.07316.27
5.4.80.0770.05716.21
5.4.70.0430.04716.32
5.4.60.0770.05716.28
5.4.50.1300.04016.32
5.4.40.1130.06316.29
5.4.30.1100.05716.18
5.4.20.0800.05316.31
5.4.10.0900.04316.38
5.4.00.1200.06715.82
5.3.290.0730.06314.83
5.3.280.1000.06314.74
5.3.270.2930.06714.72
5.3.260.1330.05314.79
5.3.250.0700.05314.72
5.3.240.0670.06014.73
5.3.230.0970.06014.67
5.3.220.0870.06714.77
5.3.210.0570.05714.80
5.3.200.0900.04014.67
5.3.190.0900.04714.57
5.3.180.0800.05314.69
5.3.170.0730.06714.67
5.3.160.3430.05014.67
5.3.150.0330.06714.58
5.3.140.0800.06714.68
5.3.130.3230.05714.75
5.3.120.0870.06014.69
5.3.110.0870.06714.73
5.3.100.0870.06014.07
5.3.90.0730.05314.13
5.3.80.0800.06714.13
5.3.70.1000.06014.14
5.3.60.0800.07314.04
5.3.50.0830.05713.98
5.3.40.0770.04013.96
5.3.30.0830.05314.06
5.3.20.0870.05713.83
5.3.10.0830.05713.79
5.3.00.0670.05313.82
5.2.170.0670.04311.24
5.2.160.0570.06011.19
5.2.150.1100.05311.39
5.2.140.0470.04711.20
5.2.130.0630.05011.19
5.2.120.0730.03711.33
5.2.110.0730.04011.12
5.2.100.0500.04711.24
5.2.90.0730.04711.25
5.2.80.0730.06011.32
5.2.70.0600.05311.16
5.2.60.0830.06011.08
5.2.50.0630.06711.26
5.2.40.0630.05311.22
5.2.30.0500.05311.10
5.2.20.0230.05011.11
5.2.10.0470.04011.07
5.2.00.0470.04010.96
5.1.60.0470.04010.04
5.1.50.0670.04310.05
5.1.40.0430.04010.02
5.1.30.0570.05010.45
5.1.20.0670.04710.50
5.1.10.0500.04010.18
5.1.00.0400.04310.11
5.0.50.0270.0308.68
5.0.40.0330.0378.42
5.0.30.0370.0578.29
5.0.20.0330.0338.32
5.0.10.0370.0278.29
5.0.00.0400.0438.28
4.4.90.0330.0305.92
4.4.80.0370.0205.96
4.4.70.0230.0275.86
4.4.60.0230.0336.00
4.4.50.0300.0275.92
4.4.40.0230.0405.88
4.4.30.0170.0305.98
4.4.20.0330.0275.92
4.4.10.0170.0275.98
4.4.00.0200.0405.91
4.3.110.0230.0205.84
4.3.100.0500.0205.80
4.3.90.0270.0305.78
4.3.80.0370.0435.81
4.3.70.0200.0405.80
4.3.60.0370.0335.79
4.3.50.0230.0235.77
4.3.40.0270.0335.73
4.3.30.0130.0234.56
4.3.20.0130.0334.57
4.3.10.0200.0274.49
4.3.00.0070.0236.69

preferences:
53.38 ms | 401 KiB | 5 Q