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); $xml->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.0110.00719.05
8.3.50.0070.01222.24
8.3.40.0150.00019.09
8.3.30.0090.00619.21
8.3.20.0050.00319.19
8.3.10.0060.00321.42
8.3.00.0040.00423.98
8.2.180.0120.00316.98
8.2.170.0090.00922.96
8.2.160.0070.00720.89
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00021.42
8.2.110.0060.00320.85
8.2.100.0080.00418.22
8.2.90.0030.00519.33
8.2.80.0030.00517.97
8.2.70.0080.00417.75
8.2.60.0000.00818.05
8.2.50.0090.00018.07
8.2.40.0060.00318.41
8.2.30.0120.00019.81
8.2.20.0000.00818.06
8.2.10.0030.00618.03
8.2.00.0030.00518.14
8.1.280.0090.01225.92
8.1.270.0040.00423.99
8.1.260.0170.00326.35
8.1.250.0100.00028.09
8.1.240.0070.00322.79
8.1.230.0040.00721.54
8.1.220.0000.00918.77
8.1.210.0050.00319.35
8.1.200.0060.00317.73
8.1.190.0030.00617.88
8.1.180.0040.00418.10
8.1.170.0040.00418.97
8.1.160.0040.00419.29
8.1.150.0000.00819.01
8.1.140.0040.00417.73
8.1.130.0030.00318.12
8.1.120.0030.00317.87
8.1.110.0040.00417.75
8.1.100.0070.00017.61
8.1.90.0060.00317.61
8.1.80.0000.00817.62
8.1.70.0030.00317.75
8.1.60.0000.00917.84
8.1.50.0040.00417.83
8.1.40.0000.00918.00
8.1.30.0020.00517.87
8.1.20.0000.01017.88
8.1.10.0000.00817.95
8.1.00.0060.00617.79
8.0.300.0040.00420.43
8.0.290.0000.00817.55
8.0.280.0080.00018.73
8.0.270.0000.00717.63
8.0.260.0030.00317.19
8.0.250.0040.00417.39
8.0.240.0000.00817.29
8.0.230.0050.00217.41
8.0.220.0030.00517.34
8.0.210.0000.00717.09
8.0.200.0000.00717.40
8.0.190.0040.00417.43
8.0.180.0040.00417.10
8.0.170.0040.00417.11
8.0.160.0000.00717.17
8.0.150.0030.00517.36
8.0.140.0070.00017.25
8.0.130.0000.00613.79
8.0.120.0020.00515.45
8.0.110.0010.00615.39
8.0.100.0060.00215.34
8.0.90.0030.00515.42
8.0.80.0050.00715.45
8.0.70.0050.00215.51
8.0.60.0040.00315.42
8.0.50.0040.00315.41
8.0.30.0060.00916.16
8.0.20.0110.00616.39
8.0.10.0050.00315.59
8.0.00.0100.00616.14
7.4.330.0060.00017.05
7.4.320.0080.00017.06
7.4.300.0030.00317.02
7.4.290.0030.00517.02
7.4.280.0000.00716.90
7.4.270.0100.00016.97
7.4.260.0060.00013.56
7.4.250.0040.00415.27
7.4.240.0020.00415.21
7.4.230.0030.00415.30
7.4.220.0030.00915.32
7.4.210.0060.00816.25
7.4.200.0020.00515.26
7.4.190.0000.00715.35
7.4.180.0000.00613.71
7.4.160.0060.00915.32
7.4.150.0050.00715.55
7.4.140.0070.00616.42
7.4.130.0070.00715.75
7.4.120.0060.00915.79
7.4.110.0090.00315.15
7.4.100.0030.00915.41
7.4.90.0050.00615.25
7.4.80.0070.00516.52
7.4.70.0040.00815.29
7.4.60.0050.00815.22
7.4.50.0040.00315.19
7.4.40.0030.00618.12
7.4.30.0030.00815.15
7.4.20.0000.00613.56
7.4.10.0000.00613.57
7.4.00.0080.00314.40
7.3.330.0000.00613.54
7.3.320.0000.00513.61
7.3.310.0030.00515.15
7.3.300.0070.00015.23
7.3.290.0050.00915.32
7.3.280.0120.00316.06
7.3.270.0050.00915.44
7.3.260.0090.01017.09
7.3.250.0070.00715.90
7.3.240.0080.00715.37
7.3.230.0100.00415.40
7.3.220.0060.00313.64
7.3.210.0090.00415.26
7.3.200.0080.00616.57
7.3.190.0070.00615.24
7.3.180.0020.00915.15
7.3.170.0040.00615.10
7.3.160.0060.00615.22
7.3.150.0030.00313.72
7.3.140.0030.00313.68
7.3.130.0060.00013.74
7.3.120.0060.00614.27
7.3.110.0030.00313.52
7.3.100.0000.00613.43
7.3.90.0030.00314.02
7.3.80.0000.00613.64
7.3.70.0030.00313.55
7.3.60.0030.00313.69
7.3.50.0060.00013.48
7.3.40.0000.00613.64
7.3.30.0050.00013.77
7.3.20.0000.00615.45
7.3.10.0040.00416.07
7.3.00.0070.00216.08
7.2.340.0090.00413.48
7.2.330.0130.00315.42
7.2.320.0070.00915.26
7.2.310.0120.00515.13
7.2.300.0080.00815.14
7.2.290.0090.00515.05
7.2.280.0040.00713.33
7.2.270.0100.00013.25
7.2.260.0080.00413.68
7.2.250.0050.00513.45
7.2.240.0000.01013.14
7.2.230.0000.01013.54
7.2.220.0110.00013.40
7.2.210.0060.00613.42
7.2.200.0080.00213.23
7.2.190.0050.00513.41
7.2.180.0030.00613.74
7.2.170.0080.00413.50
7.2.160.0070.00313.52
7.2.150.0060.00315.27
7.2.140.0060.00615.32
7.2.130.0040.00716.23
7.2.120.0080.00316.25
7.2.110.0040.00916.09
7.2.100.0020.01215.79
7.2.90.0110.00316.34
7.2.80.0030.00816.25
7.2.70.0030.00716.31
7.2.60.0120.00416.59
7.2.50.0050.00716.04
7.2.40.0100.00316.26
7.2.30.0080.00316.17
7.2.20.0110.00216.22
7.2.10.0090.00316.32
7.2.00.0080.00617.29
7.1.330.0080.00314.41
7.1.320.0050.00514.20
7.1.310.0080.00314.29
7.1.300.0130.00014.13
7.1.290.0030.00714.25
7.1.280.0080.00314.32
7.1.270.0030.00614.32
7.1.260.0070.00214.11
7.1.250.0100.00015.17
7.1.240.0050.00514.09
7.1.230.0090.00013.98
7.1.220.0050.00414.44
7.1.210.0050.00514.55
7.1.200.0090.00515.09
7.1.190.0030.00614.43
7.1.180.0100.00014.25
7.1.170.0080.00414.30
7.1.160.0100.00014.34
7.1.150.0070.00414.50
7.1.140.0000.00914.24
7.1.130.0070.00314.71
7.1.120.0060.00514.63
7.1.110.0040.00414.33
7.1.100.0060.00414.21
7.1.90.0030.00714.47
7.1.80.0050.00514.35
7.1.70.0050.00515.71
7.1.60.0020.00715.92
7.1.50.0150.00724.86
7.1.40.0080.00314.79
7.1.30.0060.00614.56
7.1.20.0040.00714.46
7.1.10.0000.01014.27
7.1.00.0080.02818.63
7.0.330.0050.00514.40
7.0.320.0070.00314.23
7.0.310.0090.00414.45
7.0.300.0070.00314.48
7.0.290.0110.00014.30
7.0.280.0100.00014.32
7.0.270.0040.00614.45
7.0.260.0090.00214.28
7.0.250.0090.00314.66
7.0.240.0100.00314.64
7.0.230.0110.00014.15
7.0.220.0080.00414.52
7.0.210.0060.00614.63
7.0.200.0030.01215.50
7.0.190.0120.00214.50
7.0.180.0040.00414.37
7.0.170.0040.00714.59
7.0.160.0040.00514.35
7.0.150.0000.00814.49
7.0.140.0060.03218.23
7.0.130.0080.00314.24
7.0.120.0080.00414.49
7.0.110.0130.00014.33
7.0.100.0090.00314.25
7.0.90.0070.00214.30
7.0.80.0110.00214.59
7.0.70.0040.00514.24
7.0.60.0110.04217.04
7.0.50.0070.03816.18
7.0.40.0070.02817.41
7.0.30.0200.03717.43
7.0.20.0120.03217.54
7.0.10.0210.02717.40
7.0.00.0050.02317.27
5.6.400.0080.00013.02
5.6.390.0040.00413.09
5.6.380.0120.00012.88
5.6.370.0070.00312.89
5.6.360.0110.00013.07
5.6.350.0040.00713.34
5.6.340.0080.00013.13
5.6.330.0030.00913.11
5.6.320.0050.00512.95
5.6.310.0070.00213.04
5.6.300.0080.00012.77
5.6.290.0080.00612.82
5.6.280.0030.04017.23
5.6.270.0110.00013.28
5.6.260.0040.00413.27
5.6.250.0060.00313.20
5.6.240.0040.00512.94
5.6.230.0060.00313.38
5.6.220.0120.00012.99
5.6.210.0100.04516.98
5.6.200.0080.04115.69
5.6.190.0050.02616.99
5.6.180.0210.03816.86
5.6.170.0180.02316.98
5.6.160.0090.04316.92
5.6.150.0050.02615.80
5.6.140.0080.03815.89
5.6.130.0030.03415.89
5.6.120.0040.04717.03
5.6.110.0020.02617.14
5.6.100.0090.03817.24
5.6.90.0110.04317.22
5.6.80.0070.04016.68
5.6.70.0130.02316.76
5.6.60.0070.00213.46
5.6.50.0060.00312.68
5.6.40.0040.00413.20
5.6.30.0060.00312.82
5.6.20.0060.00312.65
5.6.10.0030.00612.90
5.6.00.0070.00312.79
5.5.380.0070.00313.39
5.5.370.0000.00813.01
5.5.360.0100.00013.09
5.5.350.0150.04116.66
5.5.340.0090.03915.51
5.5.330.0040.02316.78
5.5.320.0150.02416.89
5.5.310.0130.02016.62
5.5.300.0030.02515.57
5.5.290.0070.04215.39
5.5.280.0080.02216.85
5.5.270.0040.03616.81
5.5.260.0040.04617.05
5.5.250.0050.03816.95
5.5.240.0090.04416.67
5.5.230.0070.00213.11
5.5.220.0040.00413.09
5.5.210.0000.00913.11
5.5.200.0020.00612.75
5.5.190.0060.00212.92
5.5.180.0040.00412.78
5.5.170.0090.00012.96
5.5.160.0050.00312.56
5.5.150.0040.00412.73
5.5.140.0080.00012.53
5.5.130.0050.00512.65
5.5.120.0050.00512.55
5.5.110.0000.00812.35
5.5.100.0050.00512.96
5.5.90.0080.00012.81
5.5.80.0000.00713.01
5.5.70.0070.00312.98
5.5.60.0060.00212.96
5.5.50.0020.00613.25
5.5.40.0050.00512.99
5.5.30.0050.00512.97
5.5.20.0050.00512.90
5.5.10.0040.00412.86
5.5.00.0060.00312.45
5.4.450.0220.03516.17
5.4.440.0170.03816.10
5.4.430.0230.02016.15
5.4.420.0220.02816.21
5.4.410.0190.04116.21
5.4.400.0230.03516.08
5.4.390.0130.02615.91
5.4.380.0130.02716.04
5.4.370.0180.03016.15
5.4.360.0150.03915.81
5.4.350.0260.02816.19
5.4.340.0210.02116.15
5.4.330.0000.00912.83
5.4.320.0180.02215.86
5.4.310.0180.02016.07
5.4.300.0140.02915.83
5.4.290.0130.02516.15
5.4.280.0120.02016.07
5.4.270.0080.02316.34
5.4.260.0150.02316.02
5.4.250.0150.02515.98
5.4.240.0120.03516.09
5.4.230.0130.03715.99
5.4.220.0210.03415.99
5.4.210.0130.02415.93
5.4.200.0100.02515.92
5.4.190.0160.02315.83
5.4.180.0140.02615.90
5.4.170.0230.03116.12
5.4.160.0180.03516.19
5.4.150.0190.02315.96
5.4.140.0160.03014.57
5.4.130.0130.02214.66
5.4.120.0170.02214.66
5.4.110.0220.02814.80
5.4.100.0150.02814.89
5.4.90.0230.03014.73
5.4.80.0130.02114.77
5.4.70.0160.01714.66
5.4.60.0140.01814.74
5.4.50.0120.02314.75
5.4.40.0100.02214.88
5.4.30.0160.01614.85
5.4.20.0160.01514.82
5.4.10.0110.02214.95
5.4.00.0070.02414.32
5.3.290.0150.02413.97
5.3.280.0120.02913.93
5.3.270.0150.04014.05
5.3.260.0170.03914.01
5.3.250.0200.03014.19
5.3.240.0150.03813.94
5.3.230.0190.03113.99
5.3.220.0220.03513.94
5.3.210.0190.03613.88
5.3.200.0190.02214.02
5.3.190.0200.02314.03
5.3.180.0170.03713.97
5.3.170.0180.01713.85
5.3.160.0140.01913.80
5.3.150.0130.02114.20
5.3.140.0150.01813.89
5.3.130.0140.02013.97
5.3.120.0130.02113.86
5.3.110.0110.02313.94
5.3.100.0090.02313.50
5.3.90.0150.01713.64
5.3.80.0110.02213.49
5.3.70.0140.02213.75
5.3.60.0130.01813.90
5.3.50.0120.02013.63
5.3.40.0150.01813.70
5.3.30.0190.01213.66
5.3.20.0130.01813.50
5.3.10.0110.02013.39
5.3.00.0110.02013.38
5.2.170.0140.01312.02
5.2.160.0080.01912.07
5.2.150.0160.01411.88
5.2.140.0070.02112.00
5.2.130.0130.01312.02
5.2.120.0150.01212.03
5.2.110.0120.01712.04
5.2.100.0080.02012.02
5.2.90.0150.01211.99
5.2.80.0110.01512.00
5.2.70.0070.01912.03
5.2.60.0080.01811.95
5.2.50.0150.01211.79
5.2.40.0110.01812.01
5.2.30.0110.01811.81
5.2.20.0220.01411.77
5.2.10.0050.01911.86
5.2.00.0100.01411.82
5.1.60.0090.01311.50
5.1.50.0090.01311.50
5.1.40.0110.01111.39
5.1.30.0070.01911.43
5.1.20.0090.01311.56
5.1.10.0090.01311.40
5.1.00.0100.01211.54
5.0.50.0070.01711.02
5.0.40.0080.02011.02
5.0.30.0050.02811.02
5.0.20.0070.01711.02
5.0.10.0070.02211.02
5.0.00.0080.02811.02
4.4.90.0050.00711.02
4.4.80.0050.00911.02
4.4.70.0040.00811.02
4.4.60.0030.01011.02
4.4.50.0050.00711.02
4.4.40.0050.01511.02
4.4.30.0040.00811.02
4.4.20.0020.01011.02
4.4.10.0050.00711.02
4.4.00.0030.02811.02
4.3.110.0070.01311.02
4.3.100.0050.01011.02
4.3.90.0050.01011.02
4.3.80.0050.03011.02
4.3.70.0090.01311.02
4.3.60.0050.01511.02
4.3.50.0060.01611.02
4.3.40.0050.02711.02
4.3.30.0040.01911.02
4.3.20.0000.02011.02
4.3.10.0030.01811.02
4.3.00.0040.01111.02

preferences:
56.59 ms | 401 KiB | 5 Q