3v4l.org

run code in 300+ PHP versions simultaneously
<?php $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->loadHTML($str); //$xml->xpath->registerNamespace("x","http://www.w3.org/1999/xhtml"); //$xml->xpath->registerNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance"); $xml->buildMissingTree($xpath); $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.70.0100.00718.68
8.3.60.0080.01219.18
8.3.50.0100.01222.24
8.3.40.0150.00619.29
8.3.30.0080.00819.28
8.3.20.0040.00419.36
8.3.10.0080.00021.59
8.3.00.0030.00620.03
8.2.180.0150.00017.25
8.2.170.0120.00322.96
8.2.160.0100.00720.68
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0080.00021.50
8.2.110.0030.00622.66
8.2.100.0060.00918.22
8.2.90.0060.00319.59
8.2.80.0030.00617.97
8.2.70.0040.00418.25
8.2.60.0080.00018.18
8.2.50.0000.00918.10
8.2.40.0050.00318.72
8.2.30.0040.00421.68
8.2.20.0000.00818.11
8.2.10.0060.00318.15
8.2.00.0060.00318.17
8.1.280.0120.00925.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00324.17
8.1.230.0110.00018.33
8.1.220.0040.00418.04
8.1.210.0000.00818.77
8.1.200.0060.00317.85
8.1.190.0000.00917.85
8.1.180.0040.00418.10
8.1.170.0030.00519.09
8.1.160.0000.00719.25
8.1.150.0040.00419.09
8.1.140.0040.00417.97
8.1.130.0000.00718.24
8.1.120.0040.00417.97
8.1.110.0040.00417.89
8.1.100.0040.00417.80
8.1.90.0050.00217.78
8.1.80.0040.00417.78
8.1.70.0050.00217.90
8.1.60.0030.00718.05
8.1.50.0040.00417.80
8.1.40.0000.00917.98
8.1.30.0000.00818.11
8.1.20.0050.00317.92
8.1.10.0000.00817.84
8.1.00.0050.00317.82
8.0.300.0030.00618.77
8.0.290.0040.00417.25
8.0.280.0030.00318.79
8.0.270.0000.00717.51
8.0.260.0000.00717.15
8.0.250.0030.00517.32
8.0.240.0000.00917.38
8.0.230.0070.00017.26
8.0.220.0080.00017.31
8.0.210.0030.00317.18
8.0.200.0050.00617.27
8.0.190.0060.00317.30
8.0.180.0040.00417.26
8.0.170.0030.00517.36
8.0.160.0000.00817.36
8.0.150.0000.00817.25
8.0.140.0020.00517.26
8.0.130.0070.00213.81
8.0.120.0000.00815.42
8.0.110.0020.00615.52
8.0.100.0040.00415.50
8.0.90.0030.00515.46
8.0.80.0060.00615.55
8.0.70.0020.00615.53
8.0.60.0050.00315.54
8.0.50.0050.00315.61
8.0.30.0060.01016.23
8.0.20.0110.00816.35
8.0.10.0070.00115.65
8.0.00.0070.00916.23
7.4.330.0000.00517.20
7.4.320.0000.00717.01
7.4.300.0030.00317.07
7.4.290.0000.00716.88
7.4.280.0030.00316.98
7.4.270.0030.00716.93
7.4.260.0060.00013.70
7.4.250.0040.00315.31
7.4.240.0060.00215.19
7.4.230.0060.00315.29
7.4.220.0070.00715.25
7.4.210.0080.00616.32
7.4.200.0020.00715.17
7.4.190.0030.00615.34
7.4.180.0040.00413.83
7.4.160.0070.00515.40
7.4.150.0060.00615.58
7.4.140.0090.00716.46
7.4.130.0090.00815.91
7.4.120.0090.00815.63
7.4.110.0120.00215.09
7.4.100.0100.00315.31
7.4.90.0090.00515.17
7.4.80.0030.01116.38
7.4.70.0060.00815.30
7.4.60.0080.00615.23
7.4.50.0020.00615.40
7.4.40.0080.00318.12
7.4.30.0080.00715.32
7.4.20.0030.00613.73
7.4.10.0090.00013.53
7.4.00.0080.00514.67
7.3.330.0040.00413.77
7.3.320.0090.00013.71
7.3.310.0060.00215.09
7.3.300.0070.00015.28
7.3.290.0040.00815.27
7.3.280.0080.00516.09
7.3.270.0100.00315.46
7.3.260.0080.00817.09
7.3.250.0110.00615.82
7.3.240.0040.01015.29
7.3.230.0070.00615.32
7.3.220.0100.00013.46
7.3.210.0040.00915.43
7.3.200.0080.00616.53
7.3.190.0100.00415.30
7.3.180.0070.00615.21
7.3.170.0060.00615.34
7.3.160.0140.00315.28
7.3.150.0000.01013.67
7.3.140.0080.00013.62
7.3.130.0000.00713.80
7.3.120.0060.00714.48
7.3.110.0080.00514.39
7.3.100.0080.00514.40
7.3.90.0000.01014.60
7.3.80.0030.00614.30
7.3.70.0010.00614.41
7.3.60.0070.00414.24
7.3.50.0000.00914.44
7.3.40.0050.00614.41
7.3.30.0030.00514.40
7.3.20.0050.00416.12
7.3.10.0050.00416.26
7.3.00.0020.00616.13
7.2.340.0060.00613.76
7.2.330.0080.00815.34
7.2.320.0060.00815.44
7.2.310.0060.01015.47
7.2.300.0150.00315.43
7.2.290.0070.00915.36
7.2.280.0050.00813.80
7.2.270.0110.00213.78
7.2.260.0120.00013.66
7.2.250.0060.00914.41
7.2.240.0070.00814.48
7.2.230.0050.01114.56
7.2.220.0100.00214.46
7.2.210.0110.00214.53
7.2.200.0060.00514.75
7.2.190.0080.00614.67
7.2.180.0050.00914.51
7.2.170.0090.00314.58
7.2.160.0100.00213.98
7.2.150.0090.00415.69
7.2.140.0120.00015.70
7.2.130.0090.00615.74
7.2.120.0150.00015.74
7.2.110.0040.00815.72
7.2.100.0090.00415.79
7.2.90.0130.00015.50
7.2.80.0060.00615.72
7.2.70.0060.00615.68
7.2.60.0080.00616.20
7.2.50.0070.00616.45
7.2.40.0130.00015.70
7.2.30.0090.00415.65
7.2.20.0090.00415.82
7.2.10.0110.00315.76
7.2.00.0040.00915.54
7.1.330.0090.00415.28
7.1.320.0040.00915.19
7.1.310.0090.00315.18
7.1.300.0060.00515.30
7.1.290.0070.00915.29
7.1.280.0080.00615.11
7.1.270.0070.00515.23
7.1.260.0080.00615.25
7.1.250.0090.00314.54
7.1.240.0060.00614.59
7.1.230.0040.00814.59
7.1.220.0000.01214.64
7.1.210.0100.00214.66
7.1.200.0080.00615.23
7.1.190.0100.00314.71
7.1.180.0090.00314.53
7.1.170.0120.00014.46
7.1.160.0000.01114.54
7.1.150.0040.00914.41
7.1.140.0060.00614.60
7.1.130.0120.00014.51
7.1.120.0090.00314.41
7.1.110.0000.01214.47
7.1.100.0060.00614.61
7.1.90.0000.01214.35
7.1.80.0000.01214.68
7.1.70.0070.00415.85
7.1.60.0060.00716.08
7.1.50.0070.00515.87
7.1.40.0060.00715.59
7.1.30.0070.00515.69
7.1.20.0080.00615.68
7.1.10.0030.00715.67
7.1.00.0080.00215.72
7.0.330.0000.01214.46
7.0.320.0040.00814.54
7.0.310.0120.00014.56
7.0.300.0110.00014.48
7.0.290.0080.00414.49
7.0.280.0110.00014.51
7.0.270.0140.00014.53
7.0.260.0080.00414.53
7.0.250.0120.00014.68
7.0.240.0060.00614.64
7.0.230.0090.00414.65
7.0.220.0090.00314.52
7.0.210.0040.00814.69
7.0.200.0050.00515.65
7.0.190.0040.00515.81
7.0.180.0040.00615.53
7.0.170.0060.00415.52
7.0.160.0070.00515.37
7.0.150.0060.00315.42
7.0.140.0060.00515.50
7.0.130.0030.00715.64
7.0.120.0090.00215.67
7.0.110.0020.00815.50
7.0.100.0070.00315.50
7.0.90.0080.00415.60
7.0.80.0130.00215.47
7.0.70.0070.00315.54
7.0.60.0070.00515.34
7.0.50.0060.00415.49
7.0.40.0050.00414.85
7.0.30.0050.00514.86
7.0.20.0040.00514.86
7.0.10.0070.00414.91
7.0.00.0080.00214.87
5.6.400.0060.00613.18
5.6.390.0100.00213.05
5.6.380.0080.00413.04
5.6.370.0110.00212.93
5.6.360.0060.00613.19
5.6.350.0080.00313.25
5.6.340.0060.00613.17
5.6.330.0060.00613.08
5.6.320.0120.00013.18
5.6.310.0130.00013.30
5.6.300.0090.02217.03
5.6.290.0060.02417.04
5.6.280.0070.02117.25
5.6.270.0060.02817.26
5.6.260.0080.02217.15
5.6.250.0070.01917.09
5.6.240.0080.02117.16
5.6.230.0080.02617.19
5.6.220.0080.02717.14
5.6.210.0060.02317.15
5.6.200.0060.02517.28
5.6.190.0050.02417.30
5.6.180.0060.02217.25
5.6.170.0070.02017.12
5.6.160.0060.02217.11
5.6.150.0020.02717.28
5.6.140.0050.02217.31
5.6.130.0090.03517.22
5.6.120.0050.02417.26
5.6.110.0080.02817.09
5.6.100.0020.02917.10
5.6.90.0080.02017.05
5.6.80.0040.02416.78
5.6.70.0060.02416.77
5.6.60.0050.02316.89
5.6.50.0110.02116.74
5.6.40.0050.02316.72
5.6.30.0100.01916.85
5.6.20.0070.02116.84
5.6.10.0030.02316.79
5.6.00.0080.02116.79
5.5.380.0050.02315.60
5.5.370.0060.02115.62
5.5.360.0060.02315.52
5.5.350.0070.02515.49
5.5.340.0040.02815.68
5.5.330.0050.02215.79
5.5.320.0030.02515.69
5.5.310.0080.01915.70
5.5.300.0040.03015.64
5.5.290.0060.02515.68
5.5.280.0070.02815.66
5.5.270.0050.04315.72
5.5.260.0080.02915.71
5.5.250.0090.02115.73
5.5.240.0060.02615.53
5.5.230.0040.02415.17
5.5.220.0060.02015.44
5.5.210.0030.02415.37
5.5.200.0070.02015.27
5.5.190.0090.01915.44
5.5.180.0070.02115.38
5.5.170.0110.00013.04
5.5.160.0020.02615.35
5.5.150.0040.02315.25
5.5.140.0030.02815.12
5.5.130.0040.02315.37
5.5.120.0040.02215.14
5.5.110.0030.02315.28
5.5.100.0020.02615.24
5.5.90.0080.02015.16
5.5.80.0020.02415.32
5.5.70.0060.02315.44
5.5.60.0090.01815.33
5.5.50.0040.02115.35
5.5.40.0040.02315.35
5.5.30.0050.02115.34
5.5.20.0050.02215.30
5.5.10.0040.02715.32
5.5.00.0040.02215.35
5.4.450.0030.03116.39
5.4.440.0070.02116.34
5.4.430.0070.02316.39
5.4.420.0060.02016.34
5.4.410.0030.02616.26
5.4.400.0080.02016.17
5.4.390.0040.02516.16
5.4.380.0070.02416.08
5.4.370.0090.01816.04
5.4.360.0080.01816.20
5.4.350.0090.02016.15
5.4.340.0070.02116.25
5.4.330.0120.00012.89
5.4.320.0070.02216.19
5.4.310.0040.02216.23
5.4.300.0050.02216.27
5.4.290.0090.02016.27
5.4.280.0040.03816.20
5.4.270.0080.01916.05
5.4.260.0080.01916.08
5.4.250.0070.01816.29
5.4.240.0000.02616.15
5.4.230.0090.01916.07
5.4.220.0050.02016.20
5.4.210.0070.02116.06
5.4.200.0050.02116.05
5.4.190.0060.02116.10
5.4.180.0040.02216.08
5.4.170.0070.01915.97
5.4.160.0000.02616.16
5.4.150.0040.02716.12
5.4.140.0060.02114.99
5.4.130.0040.02014.94
5.4.120.0170.01514.90
5.4.110.0050.02014.98
5.4.100.0060.01814.95
5.4.90.0020.02414.89
5.4.80.0080.01614.98
5.4.70.0080.01615.00
5.4.60.0060.02015.07
5.4.50.0070.01914.88
5.4.40.0030.02514.85
5.4.30.0070.01715.04
5.4.20.0070.02215.03
5.4.10.0040.02215.09
5.4.00.0060.01814.52
5.3.290.0050.02214.31
5.3.280.0070.02014.36
5.3.270.0030.03014.38
5.3.260.0060.02014.39
5.3.250.0060.01914.31
5.3.240.0030.02414.36
5.3.230.0110.01514.29
5.3.220.0030.02214.26
5.3.210.0040.02214.29
5.3.200.0060.02114.24
5.3.190.0050.02214.38
5.3.180.0000.02614.48
5.3.170.0060.02014.49
5.3.160.0070.02214.45
5.3.150.0060.02514.43
5.3.140.0020.02314.41
5.3.130.0020.02714.33
5.3.120.0080.02414.42
5.3.110.0020.02714.41
5.3.100.0040.02314.31
5.3.90.0030.02114.35
5.3.80.0050.02214.23
5.3.70.0140.01814.23
5.3.60.0030.02114.29
5.3.50.0050.02714.37
5.3.40.0070.02214.40
5.3.30.0040.02014.27
5.3.20.0040.04014.27
5.3.10.0040.02214.31
5.3.00.0050.03214.16
5.2.170.0030.01913.75
5.2.160.0090.02013.87
5.2.150.0010.02013.86
5.2.140.0050.02013.82
5.2.130.0040.02313.82
5.2.120.0080.01313.74
5.2.110.0030.01913.75
5.2.100.0130.01713.73
5.2.90.0050.01613.82
5.2.80.0020.01913.65
5.2.70.0020.02013.83
5.2.60.0050.01613.75
5.2.50.0060.01413.69
5.2.40.0040.01513.78
5.2.30.0050.01613.67
5.2.20.0020.01813.75
5.2.10.0020.01713.75
5.2.00.0050.01813.69
5.1.60.0040.01713.22
5.1.50.0050.01413.32
5.1.40.0010.01713.38
5.1.30.0030.01613.30
5.1.20.0050.01713.41
5.1.10.0080.01113.39
5.1.00.0050.01313.37
5.0.50.0050.01012.93
5.0.40.0050.01012.87
5.0.30.0030.01612.87
5.0.20.0080.00712.87
5.0.10.0000.01712.87
5.0.00.0020.01712.87
4.4.90.0050.00512.87
4.4.80.0020.00812.87
4.4.70.0020.00912.87
4.4.60.0020.00812.87
4.4.50.0020.00912.87
4.4.40.0040.01212.87
4.4.30.0020.00812.87
4.4.20.0030.00812.87
4.4.10.0030.01212.87
4.4.00.0020.01512.87
4.3.110.0020.00912.87
4.3.100.0000.01012.87
4.3.90.0010.01212.87
4.3.80.0040.02712.87
4.3.70.0020.00912.87
4.3.60.0020.01012.87
4.3.50.0020.00912.87
4.3.40.0000.01912.87
4.3.30.0000.01112.87
4.3.20.0010.01012.87
4.3.10.0010.00912.87
4.3.00.0020.00912.87

preferences:
47.19 ms | 401 KiB | 5 Q