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"; $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); $xpath->registerNamespace('x', $rootNamespace); $newdoc->buildMissingTree($xpath); //$xml->formatOutput = true; $newdoc->formatOutput = true; echo $newdoc->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.0040.01417.25
8.3.50.0120.00322.18
8.3.40.0160.00019.08
8.3.30.0040.01119.54
8.3.20.0040.00420.64
8.3.10.0040.00423.86
8.3.00.0040.00419.44
8.2.180.0120.00616.88
8.2.170.0150.00022.96
8.2.160.0070.00720.64
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0130.00421.29
8.2.110.0060.00322.63
8.2.100.0080.00418.09
8.2.90.0030.00519.55
8.2.80.0000.00917.97
8.2.70.0000.01217.49
8.2.60.0070.00318.18
8.2.50.0000.00818.07
8.2.40.0040.00420.12
8.2.30.0050.00218.59
8.2.20.0030.00618.18
8.2.10.0050.00318.45
8.2.00.0040.00418.21
8.1.280.0060.01025.92
8.1.270.0040.00424.09
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00619.04
8.1.230.0090.00321.08
8.1.220.0000.00817.77
8.1.210.0040.00418.77
8.1.200.0100.00017.85
8.1.190.0080.00017.73
8.1.180.0080.00018.10
8.1.170.0000.00818.91
8.1.160.0000.00722.23
8.1.150.0080.00018.94
8.1.140.0060.00317.83
8.1.130.0030.00318.23
8.1.120.0040.00417.85
8.1.110.0040.00417.59
8.1.100.0060.00317.66
8.1.90.0030.00517.61
8.1.80.0130.00017.75
8.1.70.0070.00017.58
8.1.60.0000.00818.07
8.1.50.0080.00017.73
8.1.40.0030.00517.83
8.1.30.0040.00418.05
8.1.20.0000.00818.11
8.1.10.0040.00418.00
8.1.00.0040.00417.76
8.0.300.0040.00418.77
8.0.290.0040.00417.28
8.0.280.0000.00718.78
8.0.270.0000.00717.56
8.0.260.0040.00717.60
8.0.250.0040.00417.20
8.0.240.0040.00417.42
8.0.230.0030.00517.41
8.0.220.0050.00317.14
8.0.210.0040.00417.07
8.0.200.0030.00317.18
8.0.190.0040.00417.21
8.0.180.0040.00417.09
8.0.170.0080.00017.11
8.0.160.0000.00817.38
8.0.150.0030.00517.29
8.0.140.0040.00417.24
8.0.130.0000.00613.75
8.0.120.0070.00415.45
8.0.110.0110.00015.42
8.0.100.0020.00815.48
8.0.90.0080.00215.45
8.0.80.0070.00715.39
8.0.70.0040.00515.41
8.0.60.0050.00515.51
8.0.50.0040.00615.46
8.0.30.0070.01016.13
8.0.20.0100.00616.26
8.0.10.0090.00115.63
8.0.00.0090.00515.97
7.4.330.0050.00315.00
7.4.320.0030.00316.96
7.4.300.0030.00316.77
7.4.290.0030.00316.77
7.4.280.0000.00816.83
7.4.270.0070.00016.79
7.4.260.0040.00416.95
7.4.250.0060.00115.24
7.4.240.0030.00715.88
7.4.230.0070.00315.27
7.4.220.0060.00915.33
7.4.210.0040.00915.86
7.4.200.0060.00415.32
7.4.190.0040.00615.30
7.4.180.0030.00313.80
7.4.160.0050.00615.25
7.4.150.0080.00615.51
7.4.140.0120.00516.41
7.4.130.0090.00815.80
7.4.120.0110.00515.74
7.4.110.0080.00915.20
7.4.100.0110.00415.22
7.4.90.0110.00415.16
7.4.80.0090.00616.53
7.4.70.0130.00215.19
7.4.60.0110.00415.35
7.4.50.0080.00315.29
7.4.40.0080.00715.14
7.4.30.0080.00615.11
7.4.20.0090.00513.68
7.4.10.0130.00013.52
7.4.00.0020.01214.34
7.3.330.0000.00513.78
7.3.320.0000.00613.84
7.3.310.0040.00715.19
7.3.300.0080.00215.29
7.3.290.0080.00415.33
7.3.280.0090.00816.05
7.3.270.0080.00715.61
7.3.260.0060.00915.34
7.3.250.0110.00615.85
7.3.240.0110.00315.44
7.3.230.0060.01115.09
7.3.220.0100.00413.76
7.3.210.0060.01115.01
7.3.200.0100.00816.58
7.3.190.0120.00415.08
7.3.180.0120.00215.18
7.3.170.0060.00815.11
7.3.160.0080.00615.12
7.3.150.0080.00013.62
7.3.140.0060.00313.46
7.3.130.0080.00013.51
7.3.120.0060.00414.17
7.3.110.0030.00313.52
7.3.100.0110.00013.44
7.3.90.0000.00713.77
7.3.80.0000.00713.64
7.3.70.0040.00413.71
7.3.60.0060.00013.54
7.3.50.0000.00613.44
7.3.40.0000.00613.47
7.3.30.0030.00313.77
7.3.20.0050.00215.30
7.3.10.0080.00315.82
7.3.00.0060.00515.86
7.2.340.0120.00013.61
7.2.330.0100.00715.36
7.2.320.0130.00215.25
7.2.310.0110.00715.26
7.2.300.0070.01015.41
7.2.290.0060.01215.35
7.2.280.0090.00313.50
7.2.270.0120.00013.48
7.2.260.0090.00413.74
7.2.250.0100.00213.46
7.2.240.0090.00313.80
7.2.230.0100.00313.66
7.2.220.0000.01213.75
7.2.210.0090.00313.83
7.2.200.0080.00614.02
7.2.190.0080.00413.91
7.2.180.0090.00413.61
7.2.170.0060.00613.98
7.2.160.0090.00413.75
7.2.150.0130.00015.46
7.2.140.0080.00415.38
7.2.130.0100.00316.20
7.2.120.0060.00616.12
7.2.110.0120.00516.11
7.2.100.0070.00415.99
7.2.90.0080.00516.18
7.2.80.0090.00516.12
7.2.70.0080.00616.07
7.2.60.0070.00616.43
7.2.50.0080.00816.21
7.2.40.0110.00616.18
7.2.30.0110.00216.34
7.2.20.0000.01316.17
7.2.10.0090.00616.20
7.2.00.0080.00617.44
7.1.330.0090.00314.55
7.1.320.0090.00414.56
7.1.310.0080.00414.51
7.1.300.0060.00614.77
7.1.290.0040.00814.77
7.1.280.0040.00914.82
7.1.270.0130.00014.47
7.1.260.0130.00014.55
7.1.250.0130.00415.10
7.1.240.0110.00314.50
7.1.230.0130.00014.56
7.1.220.0040.00814.61
7.1.210.0110.00214.61
7.1.200.0090.00215.45
7.1.190.0060.00614.47
7.1.180.0080.00414.73
7.1.170.0120.00014.71
7.1.160.0080.00414.59
7.1.150.0120.00014.69
7.1.140.0080.00414.68
7.1.130.0040.00814.72
7.1.120.0040.00814.46
7.1.110.0080.00414.78
7.1.100.0080.00414.70
7.1.90.0060.00614.73
7.1.80.0040.00814.71
7.1.70.0090.00515.96
7.1.60.0100.00216.00
7.1.50.0030.01315.77
7.1.40.0090.00314.50
7.1.30.0120.00014.48
7.1.20.0080.00414.64
7.1.10.0100.00214.50
7.1.00.0050.04118.49
7.0.330.0080.00414.61
7.0.320.0090.00314.62
7.0.310.0070.00514.36
7.0.300.0120.00014.33
7.0.290.0090.00314.61
7.0.280.0080.00414.64
7.0.270.0060.00614.36
7.0.260.0040.00814.33
7.0.250.0070.00514.66
7.0.240.0060.00614.39
7.0.230.0070.00714.69
7.0.220.0080.00414.36
7.0.210.0100.00214.63
7.0.200.0080.00615.85
7.0.190.0080.00414.40
7.0.180.0080.00414.47
7.0.170.0100.00214.61
7.0.160.0140.00014.42
7.0.150.0080.00514.42
7.0.140.0020.04218.43
7.0.130.0100.00214.68
7.0.120.0090.00514.33
7.0.110.0060.00614.46
7.0.100.0070.03117.32
7.0.90.0100.04017.44
7.0.80.0080.04417.19
7.0.70.0050.03217.34
7.0.60.0080.02317.39
7.0.50.0140.02317.53
7.0.40.0060.02317.26
7.0.30.0070.02317.40
7.0.20.0050.04717.42
7.0.10.0120.03017.29
7.0.00.0110.02317.31
5.6.400.0050.00613.34
5.6.390.0120.00013.30
5.6.380.0110.00012.94
5.6.370.0110.00012.88
5.6.360.0080.00413.09
5.6.350.0060.00613.07
5.6.340.0110.00013.05
5.6.330.0070.00413.07
5.6.320.0070.00412.95
5.6.310.0120.00012.84
5.6.300.0090.00413.05
5.6.290.0120.00013.16
5.6.280.0020.04217.22
5.6.270.0050.00512.93
5.6.260.0110.00012.95
5.6.250.0090.04016.98
5.6.240.0090.04417.09
5.6.230.0080.04417.02
5.6.220.0040.02516.90
5.6.210.0100.02216.94
5.6.200.0080.02317.32
5.6.190.0080.02217.17
5.6.180.0070.02217.22
5.6.170.0070.03517.17
5.6.160.0090.04517.15
5.6.150.0050.02717.18
5.6.140.0070.02317.32
5.6.130.0060.02317.21
5.6.120.0040.02717.16
5.6.110.0070.02217.24
5.6.100.0060.02517.08
5.6.90.0060.02317.07
5.6.80.0020.02516.96
5.6.70.0060.02316.76
5.6.60.0050.02216.86
5.6.50.0030.02516.93
5.6.40.0050.02216.90
5.6.30.0070.02516.88
5.6.20.0120.01516.71
5.6.10.0090.01816.92
5.6.00.0020.02516.87
5.5.380.0060.04316.97
5.5.370.0080.04516.84
5.5.360.0050.04517.00
5.5.350.0060.02317.00
5.5.340.0090.02217.00
5.5.330.0130.01817.04
5.5.320.0130.02517.21
5.5.310.0100.02717.12
5.5.300.0030.03417.14
5.5.290.0030.04016.95
5.5.280.0040.02517.01
5.5.270.0080.03117.04
5.5.260.0060.02316.99
5.5.250.0080.02217.09
5.5.240.0080.02016.95
5.5.230.0070.02416.91
5.5.220.0070.02016.92
5.5.210.0020.03216.88
5.5.200.0060.02116.78
5.5.190.0070.02016.81
5.5.180.0060.02116.73
5.5.170.0070.00413.13
5.5.160.0070.02216.79
5.5.150.0040.02316.57
5.5.140.0060.02116.58
5.5.130.0040.02416.56
5.5.120.0060.02116.66
5.5.110.0030.04516.55
5.5.100.0100.04916.68
5.5.90.0080.03916.62
5.5.80.0110.03416.74
5.5.70.0110.03516.78
5.5.60.0050.04416.75
5.5.50.0090.04016.86
5.5.40.0110.03816.75
5.5.30.0060.04416.74
5.5.20.0110.03616.85
5.5.10.0090.03616.67
5.5.00.0080.04116.57
5.4.450.0090.04316.43
5.4.440.0040.02316.25
5.4.430.0060.02416.33
5.4.420.0050.02216.44
5.4.410.0060.02316.16
5.4.400.0120.01916.30
5.4.390.0090.01915.98
5.4.380.0070.02416.10
5.4.370.0060.02215.96
5.4.360.0090.01816.15
5.4.350.0090.01816.05
5.4.340.0030.02516.05
5.4.330.0100.00313.07
5.4.320.0100.02316.24
5.4.310.0060.02016.20
5.4.300.0060.02116.15
5.4.290.0090.03016.16
5.4.280.0080.04116.01
5.4.270.0060.04316.04
5.4.260.0060.04515.93
5.4.250.0110.04016.26
5.4.240.0130.03516.01
5.4.230.0110.03815.98
5.4.220.0050.04016.03
5.4.210.0090.03516.12
5.4.200.0070.04015.95
5.4.190.0070.04016.00
5.4.180.0080.03715.92
5.4.170.0090.03816.06
5.4.160.0100.03515.83
5.4.150.0120.02216.00
5.4.140.0060.04114.76
5.4.130.0080.03514.87
5.4.120.0060.03614.72
5.4.110.0050.04014.74
5.4.100.0070.03114.75
5.4.90.0090.02514.90
5.4.80.0050.04114.97
5.4.70.0130.02814.85
5.4.60.0080.02814.96
5.4.50.0050.02414.89
5.4.40.0060.03514.78
5.4.30.0110.03414.85
5.4.20.0070.03814.79
5.4.10.0040.04014.83
5.4.00.0080.03814.37
5.3.290.0030.02314.26
5.3.280.0060.02814.19
5.3.270.0070.03914.13
5.3.260.0100.02114.29
5.3.250.0130.03214.13
5.3.240.0060.04113.94
5.3.230.0120.03814.26
5.3.220.0040.04413.96
5.3.210.0080.03614.14
5.3.200.0040.03914.01
5.3.190.0110.03814.05
5.3.180.0060.04114.22
5.3.170.0110.03014.08
5.3.160.0040.03714.06
5.3.150.0070.03414.23
5.3.140.0050.03913.98
5.3.130.0070.03413.84
5.3.120.0050.04114.01
5.3.110.0080.02513.93
5.3.100.0030.03613.80
5.3.90.0050.03213.81
5.3.80.0050.04213.75
5.3.70.0050.03813.94
5.3.60.0070.03513.73
5.3.50.0030.03413.65
5.3.40.0090.03313.47
5.3.30.0100.03813.69
5.3.20.0040.04013.55
5.3.10.0120.02813.68
5.3.00.0050.03713.45
5.2.170.0030.03311.99
5.2.160.0030.03311.93
5.2.150.0100.02712.01
5.2.140.0020.03311.85
5.2.130.0070.03211.81
5.2.120.0030.03211.79
5.2.110.0050.02911.81
5.2.100.0020.02911.98
5.2.90.0060.03011.96
5.2.80.0060.03411.99
5.2.70.0030.03711.93
5.2.60.0050.03211.86
5.2.50.0030.03111.81
5.2.40.0050.02211.81
5.2.30.0000.04011.71
5.2.20.0030.03211.76
5.2.10.0030.03011.85
5.2.00.0050.03011.64
5.1.60.0020.02811.42
5.1.50.0060.02011.41
5.1.40.0030.02911.57
5.1.30.0060.03011.63
5.1.20.0060.02711.34
5.1.10.0030.03311.32
5.1.00.0070.02411.29
5.0.50.0050.02311.00
5.0.40.0020.01911.00
5.0.30.0000.03711.00
5.0.20.0030.02111.00
5.0.10.0010.01811.00
5.0.00.0020.03711.00
4.4.90.0020.01711.00
4.4.80.0020.01711.00
4.4.70.0020.01811.00
4.4.60.0000.02111.00
4.4.50.0030.01111.00
4.4.40.0000.03011.00
4.4.30.0020.01911.00
4.4.20.0030.01711.00
4.4.10.0000.01911.00
4.4.00.0050.02311.00
4.3.110.0010.01311.00
4.3.100.0010.01511.00
4.3.90.0030.01311.00
4.3.80.0010.02711.00
4.3.70.0060.01311.00
4.3.60.0000.01911.00
4.3.50.0040.00911.00
4.3.40.0010.02511.00
4.3.30.0030.01811.00
4.3.20.0000.01911.00
4.3.10.0010.01011.00
4.3.00.0030.01611.00

preferences:
104.97 ms | 401 KiB | 5 Q