3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$xpath = "/x:bids_offers/x:market_submit/x:sem_gen_technical_offer/x:block_deloading/x:point"; $xpath = "//bids_offers//market_submit//sem_gen_technical_offer//block_deloading//point"; $xml = new EformDOMDocument("1.0", "UTF-8"); //$root = $xml->createElement("bids_offers"); //$xml->appendChild($root); //$root->appendChild($xml->createElement("market_submit")); //$xml->formatOutput = true; //echo $xml->saveXML(); $str = <<<XML <?xml version="1.0" encoding="UTF-8"?> <bids_offers> <market_submit> <sem_gen_technical_offer> </sem_gen_technical_offer> </market_submit> </bids_offers> XML; $xml->loadXML($str); //$rootNamespace = $xml->lookupNamespaceUri($xml->namespaceURI); //$xml->xpath->registerNamespace('x', $rootNamespace); $xml->buildMissingTree($xpath); //$xml->formatOutput = true; $xml->formatOutput = true; echo $xml->saveXML(); class EformDOMDocument extends DOMDocument { public $xpath; public function __construct($version = null, $encoding = null) { parent::__construct($version, $encoding); $this->xpath = new DOMXPath($this); } public function setAttributeX($path, $attributeName, $attributeValue) { // check if path returns anything valid if ($this->xpath->query($path)->length == 0) { $this->buildMissingTree($path); } $this->xpath->query($path)->item(0)->setAttribute($attributeName, $attributeValue); } public function buildMissingTree($path) { $missingNodes = array(); $tempPath = $path; // build an array of missing elements in the path while ($this->xpath->query($tempPath)->length == 0) { $tempName = basename($tempPath); $tempPath = dirname($tempPath); // deal with such: testnode[@type='HOT'] or [#] if (strpos($tempName, '[') === FALSE) { // no attributes use $tempName $missingNodes[] = $this->createElement($tempName); } else { // split element name and attribute, create both separate, append attribute to element, push into the aray $tempHolder = explode('[', $tempName); $tempElement = $this->createElement($tempHolder[0]); // [1] is attribute, clean it up, split name and value if (strpos($tempHolder[1], '@') !== FALSE) { // element has attiribute if it has @ in the path piece $attParam = str_replace(array('@', '\'', ']'), '', $tempHolder[1]); $attribute = explode('=', $attParam); $tempElement->setAttribute($attribute[0], $attribute[1]); } // otherwise its a number of the node in the sequence, skip it, as if xml is generated is in order, //previous nodes should exist already $missingNodes[] = $tempElement; $tempElement = null; } } // build the structure with missing elements (use $missingNodes array) // get existing end //echo $tempPath; //var_dump($missingNodes[0]); $currentElement = $this->xpath->query($tempPath)->item(0); while (($newElement = array_pop($missingNodes)) !== NULL) { $currentElement->appendChild($newElement); $currentElement = $newElement; } } /** * Checks if document has at least one element with a name (and optional attribute) provided * * @param string $name * @return mixed */ public function hasElement($name, $attribute = '') { $elements = $this->getElementsByTagName($name); if ($elements->length > 0) { if ($attribute == '') { return true; } // if attribute provided, check through the list for the element with provided attribute for ($i = 0; $i < $elements->length; $i++) { // TODO fix that checks on attibute value too, not just name if ($elements->item($i)->hasAttribute($attribute)) { return $elements->item($i); //return true; } } } return false; } /** * * @param string $name * @param string $attributeParameters provided as "attr1name=value1;attr2name=value2...etc." * @return DOMElement */ public function createElementWithAttributes($name, $attributeParameters = '') { $element = $this->createElement($name); // atributes provided as "attr1name=value1;attr2name=value2...etc." if ($attributeParameters != '') { // separate multiple parameters $attributes = explode(';', $attributeParameters); // add parameters to the element foreach ($attributes as $attribute) { $keyvalue = explode('=', $attribute); $element->setAttribute($keyvalue[0], $keyvalue[1]); } } return $element; } }

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.0140.00718.81
8.3.50.0120.00822.14
8.3.40.0110.00419.34
8.3.30.0110.00419.29
8.3.20.0180.00020.55
8.3.10.0090.00024.06
8.3.00.0080.00021.06
8.2.180.0000.01516.75
8.2.170.0100.01022.96
8.2.160.0170.00022.63
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0150.00421.38
8.2.110.0060.00320.87
8.2.100.0100.00318.34
8.2.90.0080.00019.55
8.2.80.0080.00018.30
8.2.70.0090.00017.71
8.2.60.0000.00818.18
8.2.50.0000.00918.07
8.2.40.0040.00418.66
8.2.30.0000.00818.57
8.2.20.0040.00418.30
8.2.10.0030.00620.00
8.2.00.0040.00418.14
8.1.280.0110.00425.92
8.1.270.0040.00424.32
8.1.260.0140.00426.35
8.1.250.0070.00728.09
8.1.240.0000.00924.28
8.1.230.0080.00324.36
8.1.220.0060.00318.28
8.1.210.0060.00318.77
8.1.200.0030.00617.75
8.1.190.0040.00418.16
8.1.180.0060.00318.10
8.1.170.0060.00319.16
8.1.160.0040.00422.34
8.1.150.0040.00419.14
8.1.140.0040.00417.82
8.1.130.0040.00418.17
8.1.120.0000.00817.96
8.1.110.0040.00417.91
8.1.100.0000.00717.85
8.1.90.0000.00717.73
8.1.80.0000.00817.98
8.1.70.0070.00017.69
8.1.60.0040.00417.87
8.1.50.0040.00418.04
8.1.40.0050.00517.79
8.1.30.0040.00418.05
8.1.20.0040.00418.14
8.1.10.0000.00818.00
8.1.00.0080.00017.79
8.0.300.0070.00018.77
8.0.290.0060.00317.68
8.0.280.0050.00218.81
8.0.270.0080.00017.56
8.0.260.0040.00417.21
8.0.250.0000.00817.48
8.0.240.0030.00617.32
8.0.230.0030.00317.45
8.0.220.0040.00417.20
8.0.210.0040.00417.26
8.0.200.0070.00017.18
8.0.190.0040.00417.36
8.0.180.0050.00317.15
8.0.170.0080.00017.41
8.0.160.0000.00817.28
8.0.150.0000.00717.35
8.0.140.0040.00417.17
8.0.130.0000.00613.85
8.0.120.0040.00415.43
8.0.110.0020.00515.49
8.0.100.0060.00215.59
8.0.90.0020.00615.65
8.0.80.0080.00715.55
8.0.70.0040.00515.51
8.0.60.0010.00715.62
8.0.50.0020.00715.63
8.0.30.0140.00516.28
8.0.20.0060.01116.36
8.0.10.0040.00615.72
8.0.00.0120.00316.19
7.4.330.0030.00315.43
7.4.320.0030.00316.89
7.4.300.0030.00316.80
7.4.290.0030.00516.95
7.4.280.0000.00716.85
7.4.270.0000.00716.89
7.4.260.0000.00716.92
7.4.250.0030.00515.34
7.4.240.0040.00515.87
7.4.230.0060.00215.32
7.4.220.0100.00315.32
7.4.210.0070.00716.15
7.4.200.0000.00815.34
7.4.190.0030.00515.36
7.4.180.0000.00713.86
7.4.160.0080.00415.38
7.4.150.0040.00815.57
7.4.140.0100.00516.46
7.4.130.0090.00615.88
7.4.120.0100.00715.97
7.4.110.0080.00615.42
7.4.100.0090.00515.29
7.4.90.0030.01015.29
7.4.80.0100.00315.26
7.4.70.0110.00315.23
7.4.60.0050.00715.34
7.4.50.0030.00515.28
7.4.40.0080.00318.08
7.4.30.0080.00415.42
7.4.20.0090.00013.73
7.4.10.0040.00413.65
7.4.00.0070.00214.48
7.3.330.0040.00413.77
7.3.320.0030.00313.73
7.3.310.0010.00615.26
7.3.300.0000.00715.30
7.3.290.0080.00515.35
7.3.280.0080.00916.00
7.3.270.0050.00715.50
7.3.260.0080.00515.33
7.3.250.0080.00615.77
7.3.240.0080.00715.26
7.3.230.0030.01015.45
7.3.220.0040.00413.72
7.3.210.0090.00515.26
7.3.200.0040.00816.50
7.3.190.0050.00715.37
7.3.180.0040.00815.15
7.3.170.0050.00715.26
7.3.160.0040.00915.18
7.3.150.0000.00713.48
7.3.140.0030.00313.82
7.3.130.0050.00013.46
7.3.120.0030.00714.42
7.3.110.0000.00613.57
7.3.100.0070.00013.40
7.3.90.0000.00614.14
7.3.80.0000.00613.78
7.3.70.0020.00413.73
7.3.60.0030.00313.84
7.3.50.0060.00013.85
7.3.40.0030.00313.57
7.3.30.0060.00013.53
7.3.20.0000.00715.34
7.3.10.0070.00015.54
7.3.00.0000.00615.46
7.2.340.0080.00413.86
7.2.330.0080.00715.23
7.2.320.0110.00515.54
7.2.310.0120.00715.34
7.2.300.0070.00815.45
7.2.290.0100.00515.54
7.2.280.0100.00313.61
7.2.270.0090.00313.90
7.2.260.0080.00413.95
7.2.250.0120.00013.59
7.2.240.0110.00213.86
7.2.230.0090.00313.70
7.2.220.0060.00613.59
7.2.210.0060.00613.61
7.2.200.0140.00014.10
7.2.190.0060.00713.92
7.2.180.0100.00513.83
7.2.170.0060.00613.79
7.2.160.0090.00313.98
7.2.150.0100.00315.80
7.2.140.0100.00315.80
7.2.130.0030.01015.66
7.2.120.0100.00315.61
7.2.110.0060.00615.87
7.2.100.0070.00615.84
7.2.90.0070.00715.62
7.2.80.0130.00015.82
7.2.70.0080.00515.68
7.2.60.0100.00216.43
7.2.50.0060.00615.56
7.2.40.0090.00315.82
7.2.30.0080.00515.57
7.2.20.0110.00315.89
7.2.10.0000.01315.83
7.2.00.0180.00717.72
7.1.330.0120.00014.70
7.1.320.0000.01214.49
7.1.310.0120.00014.61
7.1.300.0080.00414.73
7.1.290.0120.00014.58
7.1.280.0060.00614.43
7.1.270.0000.01214.71
7.1.260.0040.00814.58
7.1.250.0100.00214.53
7.1.240.0110.00014.67
7.1.230.0090.00314.61
7.1.220.0120.00014.66
7.1.210.0080.00414.75
7.1.200.0100.00215.37
7.1.190.0060.00614.47
7.1.180.0080.00414.37
7.1.170.0060.00614.37
7.1.160.0060.00614.70
7.1.150.0040.00814.53
7.1.140.0120.00014.68
7.1.130.0060.00614.37
7.1.120.0000.01214.51
7.1.110.0000.01214.69
7.1.100.0110.00216.48
7.1.90.0120.00014.40
7.1.80.0120.00014.57
7.1.70.0030.00715.89
7.1.60.0090.00917.03
7.1.50.0090.00815.77
7.1.40.0090.00314.79
7.1.30.0130.00014.77
7.1.20.0100.00214.66
7.1.10.0120.00014.72
7.1.00.0020.04418.62
7.0.330.0060.00614.55
7.0.320.0000.01114.64
7.0.310.0090.00314.66
7.0.300.0090.00214.54
7.0.290.0090.00314.61
7.0.280.0090.00214.55
7.0.270.0090.00214.64
7.0.260.0080.00414.56
7.0.250.0060.00614.86
7.0.240.0120.00014.68
7.0.230.0060.00614.72
7.0.220.0120.00014.55
7.0.210.0120.00014.63
7.0.200.0110.00215.75
7.0.190.0060.00614.45
7.0.180.0040.00814.46
7.0.170.0080.00414.76
7.0.160.0040.00814.39
7.0.150.0060.00614.68
7.0.140.0030.04318.26
7.0.130.0120.00014.74
7.0.120.0080.00414.52
7.0.110.0090.00314.65
7.0.100.0120.00014.40
7.0.90.0120.00014.64
7.0.80.0060.00614.58
7.0.70.0110.00314.45
7.0.60.0070.03417.40
7.0.50.0090.04116.35
7.0.40.0090.04417.49
7.0.30.0200.03617.45
7.0.20.0160.04317.54
7.0.10.0160.03617.49
7.0.00.0070.02017.35
5.6.400.0070.00513.06
5.6.390.0120.00013.34
5.6.380.0110.00013.28
5.6.370.0120.00013.37
5.6.360.0080.00313.19
5.6.350.0080.00312.98
5.6.340.0090.00312.93
5.6.330.0060.00613.18
5.6.320.0060.00613.47
5.6.310.0060.00613.39
5.6.300.0040.00812.97
5.6.290.0110.00012.96
5.6.280.0070.03717.32
5.6.270.0070.00413.01
5.6.260.0060.00613.26
5.6.250.0050.00513.06
5.6.240.0090.00313.23
5.6.230.0080.00413.36
5.6.220.0120.00013.60
5.6.210.0070.04216.92
5.6.200.0100.02115.81
5.6.190.0040.02717.15
5.6.180.0090.04317.09
5.6.170.0170.03917.09
5.6.160.0110.04216.94
5.6.150.0080.02115.83
5.6.140.0040.03915.90
5.6.130.0060.02815.95
5.6.120.0100.03917.29
5.6.110.0040.05117.18
5.6.100.0120.03617.29
5.6.90.0050.03117.35
5.6.80.0100.03316.98
5.6.70.2340.02017.03
5.6.60.0080.00313.41
5.6.50.0090.00213.40
5.6.40.0090.00213.30
5.6.30.0070.00413.31
5.6.20.0080.00313.07
5.6.10.0070.00413.40
5.6.00.0080.00413.14
5.5.380.0120.00013.64
5.5.370.0110.00013.48
5.5.360.0060.00613.46
5.5.350.0060.01816.95
5.5.340.0060.03815.72
5.5.330.0070.03016.82
5.5.320.0060.02116.98
5.5.310.0160.02816.86
5.5.300.0050.04815.74
5.5.290.0080.02515.67
5.5.280.0030.03117.22
5.5.270.0060.04117.14
5.5.260.0080.02617.08
5.5.250.0110.03716.94
5.5.240.0060.02216.77
5.5.230.0110.00013.38
5.5.220.0080.00413.38
5.5.210.0050.00513.15
5.5.200.0090.00313.10
5.5.190.0090.00313.20
5.5.180.0120.00013.09
5.5.170.0110.00013.38
5.5.160.0090.00213.00
5.5.150.0070.00513.32
5.5.140.0090.00313.20
5.5.130.0040.00813.26
5.5.120.0040.00813.26
5.5.110.0090.00313.27
5.5.100.0120.00013.24
5.5.90.0080.00413.25
5.5.80.0000.01113.15
5.5.70.0090.00313.34
5.5.60.0110.00013.31
5.5.50.0080.00313.05
5.5.40.0060.00613.33
5.5.30.0120.00013.41
5.5.20.0110.00013.44
5.5.10.0070.00313.14
5.5.00.0090.00313.13
5.4.450.0320.03016.38
5.4.440.0260.02116.43
5.4.430.0220.02216.59
5.4.420.0330.02316.50
5.4.410.0190.03016.23
5.4.400.0180.03015.98
5.4.390.0310.03315.93
5.4.380.0130.02815.99
5.4.370.0130.02316.06
5.4.360.0130.02216.02
5.4.350.0020.03416.12
5.4.340.0060.02815.88
5.4.330.0040.00713.08
5.4.320.0090.01913.04
5.4.310.0090.01913.11
5.4.300.0070.02013.16
5.4.290.0120.02413.04
5.4.280.0070.02313.07
5.4.270.0100.01913.04
5.4.260.0080.02112.95
5.4.250.0090.01912.89
5.4.240.0100.02012.93
5.4.230.0090.02212.84
5.4.220.0100.02212.88
5.4.210.0060.02212.85
5.4.200.0120.02112.82
5.4.190.0100.02512.85
5.4.180.0130.02212.94
5.4.170.0120.02312.84
5.4.160.0130.02212.87
5.4.150.0100.02512.94
5.4.140.0110.02412.75
5.4.130.0130.02212.77
5.4.120.0080.02612.85
5.4.110.0120.02212.84
5.4.100.0150.02012.69
5.4.90.0110.02412.72
5.4.80.0110.02312.75
5.4.70.0130.02112.73
5.4.60.0120.02312.87
5.4.50.0110.02312.62
5.4.40.0110.02312.69
5.4.30.0120.02212.74
5.4.20.0140.03512.86
5.4.10.0140.02012.86
5.4.00.0150.01912.51
5.3.290.0080.02313.43
5.3.280.0090.02613.27
5.3.270.0150.02113.37
5.3.260.0140.02313.33
5.3.250.0140.02213.20
5.3.240.0150.02113.28
5.3.230.0110.02513.13
5.3.220.0150.02113.31
5.3.210.0090.02713.12
5.3.200.0200.04613.11
5.3.190.0110.02613.35
5.3.180.0130.02313.21
5.3.170.0130.02313.39
5.3.160.0110.02513.40
5.3.150.0150.03513.35
5.3.140.0100.02513.19
5.3.130.0140.03713.17
5.3.120.0090.02713.37
5.3.110.0120.02413.36
5.3.100.0110.02513.05
5.3.90.0120.02312.97
5.3.80.0100.02612.99
5.3.70.0110.02612.90
5.3.60.0160.05012.88
5.3.50.0110.02412.99
5.3.40.0130.02212.98
5.3.30.0100.02412.98
5.3.20.0130.02212.68
5.3.10.0120.02212.58
5.3.00.0250.03912.69
5.2.170.0080.02011.11
5.2.160.0080.02011.02
5.2.150.0090.01910.94
5.2.140.0060.02210.91
5.2.130.0100.01810.86
5.2.120.0070.02110.88
5.2.110.0090.02011.06
5.2.100.0110.01710.86
5.2.90.0090.01911.02
5.2.80.0100.01810.82
5.2.70.0120.01711.00
5.2.60.0070.02110.76
5.2.50.0100.01910.93
5.2.40.0140.04510.79
5.2.30.0130.01510.95
5.2.20.0070.02110.83
5.2.10.0070.02010.75
5.2.00.0100.01710.72
5.1.60.0070.0179.82
5.1.50.0080.0169.78
5.1.40.0100.0149.89
5.1.30.0080.01710.14
5.1.20.0060.02010.11
5.1.10.0090.0179.91
5.1.00.0080.0189.80
5.0.50.0060.0158.80
5.0.40.0080.0128.67
5.0.30.0070.0348.58
5.0.20.0050.0148.56
5.0.10.0090.0108.55
5.0.00.0080.0188.52
4.4.90.0040.0097.63
4.4.80.0060.0077.62
4.4.70.0060.0097.63
4.4.60.0050.0097.62
4.4.50.0070.0077.63
4.4.40.0070.0277.60
4.4.30.0040.0117.63
4.4.20.0020.0127.67
4.4.10.0040.0117.67
4.4.00.0050.0157.62
4.3.110.0060.0087.58
4.3.100.0040.0107.58
4.3.90.0050.0097.56
4.3.80.0020.0177.54
4.3.70.0060.0077.56
4.3.60.0020.0117.56
4.3.50.0040.0107.56
4.3.40.0040.0157.51
4.3.30.0020.0116.90
4.3.20.0050.0096.90
4.3.10.0040.0096.87
4.3.00.0050.01013.02

preferences:
43.32 ms | 401 KiB | 5 Q