3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* XML Parser Class by Eric Rosebrock modified by Richard Bishop 30/05/2007 http://www.phpfreaks.com Class originated from: kris@h3x.com AT: http://www.devdump.com/phpxml.php Usage: <?php include 'clsParseXML.php'; $xmlparse = &new ParseXML; $xml = $xmlparse->GetXMLTree('/path/to/xmlfile.xml'); echo "<pre>"; print_r($xml); echo "</pre>"; ?> The path to the XML file may be a local file or a URL. Returns the elements of the XML file into an array with it's subelements as keys and subarrays. */ class clsParseXML{ function GetChildren($vals, &$i) { $children = array(); // Contains node data if (isset($vals[$i]['value'])){ $children['VALUE'] = $vals[$i]['value']; } while (++$i < count($vals)){ switch ($vals[$i]['type']){ case 'cdata': if (isset($children['VALUE'])){ $children['VALUE'] .= $vals[$i]['value']; } else { $children['VALUE'] = $vals[$i]['value']; } break; case 'complete': if (isset($vals[$i]['attributes'])) { $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($children[$vals[$i]['tag']])-1; if (isset($vals[$i]['value'])){ $children[$vals[$i]['tag']][$index]['VALUE'] = $vals[$i]['value']; } else { $children[$vals[$i]['tag']][$index]['VALUE'] = ''; } } else { if (isset($vals[$i]['value'])){ $children[$vals[$i]['tag']][]['VALUE'] = $vals[$i]['value']; } else { $children[$vals[$i]['tag']][]['VALUE'] = ''; } } break; case 'open': if (isset($vals[$i]['attributes'])) { $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($children[$vals[$i]['tag']])-1; $children[$vals[$i]['tag']][$index] = array_merge($children[$vals[$i]['tag']][$index],$this->GetChildren($vals, $i)); } else { $children[$vals[$i]['tag']][] = $this->GetChildren($vals, $i); } break; case 'close': return $children; } } } function GetXMLDataTree($data){ $parser = xml_parser_create('ISO-8859-1'); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); $tree = array(); $i = 0; if (isset($vals[$i]['attributes'])) { $tree[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($tree[$vals[$i]['tag']])-1; $tree[$vals[$i]['tag']][$index] = array_merge($tree[$vals[$i]['tag']][$index], $this->GetChildren($vals, $i)); } else { $tree[$vals[$i]['tag']][] = $this->GetChildren($vals, $i); } return $tree; } function GetXMLTree($xmlloc){ if (file_exists($xmlloc)){ $data = implode('', file($xmlloc)); } else { $fp = fopen($xmlloc,'r'); while(!feof($fp)){ $data = $data . fread($fp, 1024); } fclose($fp); } $parser = xml_parser_create('ISO-8859-1'); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); $tree = array(); $i = 0; if (isset($vals[$i]['attributes'])) { $tree[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes']; $index = count($tree[$vals[$i]['tag']])-1; $tree[$vals[$i]['tag']][$index] = array_merge($tree[$vals[$i]['tag']][$index], $this->GetChildren($vals, $i)); } else { $tree[$vals[$i]['tag']][] = $this->GetChildren($vals, $i); } return $tree; } } ?>

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.40.0110.00718.57
8.3.30.0140.00019.10
8.3.20.0040.00420.34
8.3.10.0070.00723.66
8.3.00.0030.00519.02
8.2.170.0120.00322.96
8.2.160.0040.01120.53
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00721.12
8.2.110.0070.00320.57
8.2.100.0040.00717.78
8.2.90.0000.01019.45
8.2.80.0060.00319.10
8.2.70.0040.00417.38
8.2.60.0000.00817.80
8.2.50.0060.00318.07
8.2.40.0000.00821.13
8.2.30.0040.00417.94
8.2.20.0080.00017.62
8.2.10.0040.00417.90
8.2.00.0080.00017.59
8.1.270.0000.00922.12
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0130.00322.41
8.1.230.0090.00320.87
8.1.220.0000.00817.74
8.1.210.0030.00718.91
8.1.200.0060.00317.35
8.1.190.0030.00517.10
8.1.180.0080.00018.10
8.1.170.0090.00018.52
8.1.160.0070.00018.78
8.1.150.0030.00618.57
8.1.140.0080.00017.43
8.1.130.0000.00717.73
8.1.120.0000.00717.31
8.1.110.0000.00917.27
8.1.100.0000.00817.35
8.1.90.0040.00417.29
8.1.80.0040.00417.36
8.1.70.0040.00417.29
8.1.60.0040.00417.43
8.1.50.0030.00517.34
8.1.40.0030.00917.46
8.1.30.0050.00317.49
8.1.20.0000.00817.64
8.1.10.0060.00317.42
8.1.00.0030.00517.39
8.0.300.0070.00019.89
8.0.290.0000.00716.75
8.0.280.0070.00018.43
8.0.270.0000.00717.88
8.0.260.0030.00317.19
8.0.250.0040.00416.90
8.0.240.0000.00816.84
8.0.230.0030.00316.89
8.0.220.0030.00316.76
8.0.210.0000.00716.91
8.0.200.0030.00616.86
8.0.190.0000.00916.95
8.0.180.0070.00016.93
8.0.170.0040.00416.86
8.0.160.0030.00316.86
8.0.150.0000.00716.68
8.0.140.0050.00316.68
8.0.130.0030.00313.26
8.0.120.0060.00316.79
8.0.110.0000.00716.75
8.0.100.0080.00016.86
8.0.90.0040.00416.84
8.0.80.0160.00016.80
8.0.70.0050.00316.89
8.0.60.0070.00016.87
8.0.50.0080.00016.83
8.0.30.0130.01217.13
8.0.20.0120.00617.40
8.0.10.0020.00516.99
8.0.00.0080.01216.69
7.4.330.0030.00515.03
7.4.320.0070.00016.45
7.4.300.0000.00616.44
7.4.290.0030.00616.54
7.4.280.0040.00416.53
7.4.270.0030.00316.55
7.4.260.0000.00716.54
7.4.250.0080.00016.52
7.4.240.0040.00416.51
7.4.230.0070.00016.56
7.4.220.0170.00716.49
7.4.210.0000.02016.61
7.4.200.0040.00416.43
7.4.160.0090.00616.42
7.4.150.0160.01117.40
7.4.140.0140.00917.86
7.4.130.0070.01416.49
7.4.120.0080.01016.35
7.4.110.0090.00916.43
7.4.100.0100.01116.60
7.4.90.0090.00916.39
7.4.80.0000.01819.39
7.4.70.0120.00916.48
7.4.60.0170.00016.50
7.4.50.0030.00516.35
7.4.40.0100.00616.41
7.4.30.0030.01416.50
7.4.10.0110.00715.02
7.4.00.0050.01314.88
7.3.330.0050.00013.10
7.3.320.0020.00213.06
7.3.310.0080.00016.09
7.3.300.0070.00016.23
7.3.290.0090.00816.23
7.3.280.0070.01216.18
7.3.270.0100.00717.40
7.3.260.0100.00716.29
7.3.250.0080.01016.40
7.3.240.0190.00716.40
7.3.230.0070.01316.49
7.3.210.0120.00316.50
7.3.200.0100.00719.39
7.3.190.0060.00916.38
7.3.180.0040.01816.35
7.3.170.0110.01116.27
7.3.160.0100.01016.53
7.3.130.0070.01314.63
7.3.120.0060.01315.57
7.3.110.0070.01115.59
7.3.100.0030.01015.59
7.3.90.0030.01215.52
7.3.80.0040.00815.53
7.3.70.0060.00615.53
7.3.60.0020.01115.53
7.3.50.0040.00915.49
7.3.40.0060.00615.49
7.3.30.0020.01115.57
7.3.20.0060.00716.71
7.3.10.0110.00616.48
7.3.00.0090.00816.47
7.2.330.0060.01316.20
7.2.320.0030.01316.58
7.2.310.0070.01116.66
7.2.300.0040.01416.56
7.2.290.0100.00716.36
7.2.260.0070.00715.00
7.2.250.0050.01315.02
7.2.240.0080.00815.72
7.2.230.0080.00615.60
7.2.220.0050.00915.57
7.2.210.0030.01115.59
7.2.200.0050.00915.69
7.2.190.0090.00515.58
7.2.180.0050.00715.53
7.2.170.0050.01115.54
7.2.160.0020.01316.07
7.2.150.0020.01316.92
7.2.140.0020.01416.96
7.2.130.0080.01116.53
7.2.120.0100.01016.77
7.2.110.0130.00616.59
7.2.100.0090.00716.72
7.2.90.0060.00916.71
7.2.80.0080.01016.79
7.2.70.0080.00916.69
7.2.60.0080.01016.68
7.2.50.0130.00616.59
7.2.40.0080.00816.56
7.2.30.0090.01016.75
7.2.20.0090.00616.69
7.2.10.0060.00816.70
7.2.00.0050.01017.44
7.1.330.0060.00716.13
7.1.320.0050.00916.10
7.1.310.0030.00916.07
7.1.300.0070.00615.96
7.1.290.0030.01016.12
7.1.280.0030.01116.20
7.1.270.0040.00916.15
7.1.260.0070.00616.14
7.1.250.0130.00215.93
7.1.240.0040.00815.57
7.1.230.0040.00815.48
7.1.220.0030.00715.43
7.1.210.0000.01415.73
7.1.200.0060.00515.52
7.1.190.0000.01615.68
7.1.180.0090.00315.71
7.1.170.0060.00615.37
7.1.160.0080.00615.73
7.1.150.0090.00015.44
7.1.140.0040.00815.73
7.1.130.0060.00615.73
7.1.120.0040.00815.64
7.1.110.0030.00715.63
7.1.100.0060.00616.61
7.1.90.0000.00915.73
7.1.80.0110.00415.78
7.1.70.0080.00516.34
7.1.60.0020.01316.46
7.1.50.0110.00616.26
7.1.40.0110.00415.70
7.1.30.0090.00615.38
7.1.20.0030.01515.70
7.1.10.0060.00615.57
7.1.00.0020.04418.87
7.0.330.0080.00614.90
7.0.320.0030.01015.01
7.0.310.0030.00714.96
7.0.300.0090.00615.37
7.0.290.0030.00915.25
7.0.280.0030.00714.92
7.0.270.0070.00315.20
7.0.260.0050.00315.16
7.0.250.0040.01215.47
7.0.240.0000.01115.08
7.0.230.0130.00015.46
7.0.220.0100.00615.09
7.0.210.0100.00615.35
7.0.200.0080.01115.88
7.0.190.0070.00415.45
7.0.180.0040.01115.30
7.0.170.0000.00815.21
7.0.160.0040.00715.35
7.0.150.0060.00615.29
7.0.140.0060.02118.65
7.0.130.0060.00615.36
7.0.120.0140.00015.34
7.0.110.0070.00615.35
7.0.100.0070.01114.98
7.0.90.0030.00615.36
7.0.80.0070.00715.07
7.0.70.0060.00315.21
7.0.60.0080.04317.51
7.0.50.0140.03716.54
7.0.40.0080.04016.90
7.0.30.0120.02316.57
7.0.20.0160.02916.78
7.0.10.0050.03716.75
7.0.00.0050.04516.79
5.6.400.0040.01114.41
5.6.390.0100.00314.26
5.6.380.0080.00414.09
5.6.370.0000.01414.45
5.6.360.0030.01014.09
5.6.350.0030.00514.34
5.6.340.0040.01113.96
5.6.330.0080.00413.93
5.6.320.0040.01414.29
5.6.310.0100.00314.36
5.6.300.0060.00614.19
5.6.290.0000.00814.08
5.6.280.0050.04117.58
5.6.270.0060.01214.14
5.6.260.0100.00713.94
5.6.250.0000.01514.14
5.6.240.0090.00314.20
5.6.230.0040.01114.01
5.6.220.0090.00314.16
5.6.210.0070.04317.64
5.6.200.0070.04116.19
5.6.190.0060.02617.30
5.6.180.0150.03517.32
5.6.170.0170.03017.32
5.6.160.0050.02817.45
5.6.150.0020.02516.21
5.6.140.0110.04416.15
5.6.130.0110.01916.03
5.6.120.0080.04517.60
5.6.110.0100.04717.47
5.6.100.0070.04117.64
5.6.90.0130.03917.57
5.6.80.0040.04717.28
5.6.70.0030.00914.12
5.6.60.0000.01014.00
5.6.50.0030.01013.93
5.6.40.0060.00314.20
5.6.30.0000.01514.02
5.6.20.0030.01014.28
5.6.10.0030.01014.14
5.6.00.0000.01914.09
5.5.380.0030.01014.03
5.5.370.0000.01414.17
5.5.360.0040.01114.04
5.5.350.2130.02317.27
5.5.340.0060.04115.85
5.5.330.0050.02917.05
5.5.320.0140.04217.21
5.5.310.0230.03817.21
5.5.300.0180.02115.98
5.5.290.0130.04016.10
5.5.280.0030.05017.52
5.5.270.0100.04117.59
5.5.260.0070.04717.57
5.5.250.0050.04217.32
5.5.240.0070.03817.06
5.5.230.0000.01814.09
5.5.220.0000.01313.91
5.5.210.0000.00913.97
5.5.200.0100.00713.98
5.5.190.0030.01013.73
5.5.180.0150.00013.84
5.5.170.0030.00814.03
5.5.160.0100.00613.91
5.5.150.0070.01114.15
5.5.140.0110.00413.75
5.5.130.0030.00714.03
5.5.120.0040.01114.10
5.5.110.0040.01414.01
5.5.100.0030.00913.90
5.5.90.0040.00713.97
5.5.80.0000.01213.98
5.5.70.0000.01314.08
5.5.60.0060.00314.15
5.5.50.0080.00314.18
5.5.40.0080.00413.87
5.5.30.0040.00814.13
5.5.20.0060.00613.90
5.5.10.0030.01013.87
5.5.00.0030.00913.90
5.4.450.0460.02915.11
5.4.440.0500.02815.30
5.4.430.0370.02715.30
5.4.420.0300.03715.10
5.4.410.0350.03214.91
5.4.400.0320.03015.02
5.4.390.0180.04214.84
5.4.380.0170.03314.87
5.4.370.0220.02914.77
5.4.360.0190.03114.82
5.4.350.0290.03714.83
5.4.340.0200.02914.67
5.4.330.0070.00411.02
5.4.320.0290.03714.65
5.4.310.0180.03314.51
5.4.300.0180.03514.65
5.4.290.0180.03714.61
5.4.280.0200.03214.73
5.4.270.0220.03214.58
5.4.260.0200.03514.62
5.4.250.0270.02714.77
5.4.240.0170.03414.72
5.4.230.0340.03014.52
5.4.220.0220.03014.76
5.4.210.0250.03714.76
5.4.200.0200.03913.55
5.4.190.0180.03214.77
5.4.180.0200.04014.75
5.4.170.0160.03314.63
5.4.160.0330.02014.68
5.4.150.0210.03614.71
5.4.140.0260.02313.49
5.4.130.0250.02613.56
5.4.120.0180.03213.72
5.4.110.0260.03013.55
5.4.100.0220.03713.58
5.4.90.0240.03513.45
5.4.80.0220.03513.50
5.4.70.0230.03413.55
5.4.60.0270.02913.68
5.4.50.0250.03213.51
5.4.40.0220.02713.67
5.4.30.0270.01913.42
5.4.20.0210.02813.42
5.4.10.0180.02813.58
5.4.00.0230.02313.19
5.3.290.0330.06014.72
5.3.280.0370.05714.82
5.3.270.0370.06314.64
5.3.260.0430.06314.64
5.3.250.0370.07714.86
5.3.240.0500.06314.68
5.3.230.0370.06014.74
5.3.220.0400.05314.73
5.3.210.0630.06314.73
5.3.200.0370.05714.70
5.3.190.0370.05314.63
5.3.180.0300.05714.79
5.3.170.0370.05314.63
5.3.160.0330.06014.64
5.3.150.0370.05714.73
5.3.140.0270.06014.76
5.3.130.0300.06314.68
5.3.120.0330.05714.61
5.3.110.0400.05714.62
5.3.100.0370.07014.18
5.3.90.0300.07014.22
5.3.80.0370.05714.27
5.3.70.0330.05714.27
5.3.60.0330.05714.12
5.3.50.0330.05014.03
5.3.40.0200.07314.10
5.3.30.0270.05713.97
5.3.20.0370.05313.77
5.3.10.0330.05313.71
5.3.00.0330.06313.67
5.2.170.0500.05011.23
5.2.160.0430.06011.17
5.2.150.0400.06011.41
5.2.140.0430.04711.26
5.2.130.0230.05311.27
5.2.120.0530.03011.14
5.2.110.0300.05711.21
5.2.100.0370.05011.15
5.2.90.0370.04311.26
5.2.80.0400.03011.15
5.2.70.0430.03711.18
5.2.60.0300.05711.20
5.2.50.0300.06011.11
5.2.40.0300.05011.12
5.2.30.0270.04711.02
5.2.20.0270.04011.05
5.2.10.0200.04011.09
5.2.00.0400.03710.89
5.1.60.0200.03710.11
5.1.50.0330.04010.24
5.1.40.0430.04310.23
5.1.30.0200.06310.38
5.1.20.0430.04310.62
5.1.10.0370.03710.13
5.1.00.0270.03710.22
5.0.50.0170.0308.75
5.0.40.0100.0308.61
5.0.30.0130.0508.42
5.0.20.0170.0378.41
5.0.10.0070.0338.38
5.0.00.0230.0578.27
4.4.90.0200.0237.38
4.4.80.0130.0307.38
4.4.70.0200.0207.38
4.4.60.0100.0237.38
4.4.50.0100.0237.38
4.4.40.0070.0507.38
4.4.30.0100.0307.38
4.4.20.0030.0407.38
4.4.10.0130.0207.38
4.4.00.0370.0437.38
4.3.110.0230.0277.38
4.3.100.0200.0277.38
4.3.90.0200.0277.38
4.3.80.0130.0337.38
4.3.70.0130.0307.38
4.3.60.0130.0277.38
4.3.50.0100.0307.38
4.3.40.0170.0407.38
4.3.30.0070.0277.38
4.3.20.0100.0277.38
4.3.10.0030.0237.38
4.3.00.0130.0207.22

preferences:
55 ms | 400 KiB | 5 Q