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->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.60.0080.00818.77
8.3.50.0110.01122.24
8.3.40.0220.00019.42
8.3.30.0070.01019.23
8.3.20.0050.00319.23
8.3.10.0040.00421.54
8.3.00.0040.00423.88
8.2.180.0070.00717.00
8.2.170.0130.01022.96
8.2.160.0100.01020.76
8.2.150.0030.00524.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0060.01320.05
8.2.110.0060.00620.87
8.2.100.0040.00818.34
8.2.90.0030.00619.55
8.2.80.0080.00018.43
8.2.70.0030.00618.00
8.2.60.0030.00618.30
8.2.50.0000.00818.07
8.2.40.0040.00418.53
8.2.30.0080.00019.85
8.2.20.0000.00718.20
8.2.10.0040.00418.26
8.2.00.0040.00418.30
8.1.280.0190.00025.92
8.1.270.0080.00023.99
8.1.260.0110.00426.35
8.1.250.0070.00328.09
8.1.240.0100.00022.76
8.1.230.0090.00321.34
8.1.220.0050.00318.77
8.1.210.0080.00019.53
8.1.200.0070.00317.98
8.1.190.0000.00818.16
8.1.180.0040.00418.20
8.1.170.0030.00618.82
8.1.160.0000.00919.39
8.1.150.0030.00618.94
8.1.140.0050.00318.01
8.1.130.0000.00918.00
8.1.120.0070.00017.78
8.1.110.0030.00617.85
8.1.100.0070.00017.91
8.1.90.0080.00017.88
8.1.80.0040.00417.92
8.1.70.0030.00317.78
8.1.60.0030.00617.92
8.1.50.0000.01017.78
8.1.40.0040.00417.96
8.1.30.0040.00418.09
8.1.20.0050.00518.10
8.1.10.0040.00417.96
8.1.00.0030.00517.82
8.0.300.0030.00620.35
8.0.290.0000.00817.55
8.0.280.0040.00419.07
8.0.270.0030.00317.72
8.0.260.0000.00717.36
8.0.250.0050.00317.44
8.0.240.0040.00417.46
8.0.230.0030.00317.31
8.0.220.0000.00917.31
8.0.210.0040.00417.38
8.0.200.0000.00917.46
8.0.190.0030.00617.31
8.0.180.0060.00317.31
8.0.170.0040.00417.46
8.0.160.0000.00817.29
8.0.150.0030.00617.31
8.0.140.0000.00817.34
8.0.130.0000.00613.87
8.0.120.0060.00615.59
8.0.110.0080.00315.61
8.0.100.0040.00715.48
8.0.90.0110.00015.58
8.0.80.0090.00815.63
8.0.70.0070.00315.63
8.0.60.0080.00215.53
8.0.50.0040.00715.63
8.0.30.0100.00816.36
8.0.20.0100.00716.29
8.0.10.0040.00615.80
8.0.00.0080.00716.07
7.4.330.0020.00515.16
7.4.320.0030.00316.96
7.4.300.0040.00417.02
7.4.290.0000.00816.98
7.4.280.0000.00716.96
7.4.270.0050.00216.98
7.4.260.0030.00313.73
7.4.250.0020.00615.40
7.4.240.0110.00115.35
7.4.230.0090.00215.32
7.4.220.0110.00515.36
7.4.210.0030.01116.42
7.4.200.0020.00815.29
7.4.190.0050.00515.53
7.4.180.0000.00813.86
7.4.160.0020.01015.29
7.4.150.0080.00515.51
7.4.140.0090.00716.47
7.4.130.0110.00615.89
7.4.120.0060.01115.84
7.4.110.0120.00315.30
7.4.100.0120.00415.34
7.4.90.0080.00915.38
7.4.80.0080.00816.53
7.4.70.0080.00815.25
7.4.60.0100.00615.41
7.4.50.0060.00515.28
7.4.40.0050.01018.03
7.4.30.0080.00815.16
7.4.20.0070.00313.71
7.4.10.0090.00414.34
7.4.00.0070.00914.59
7.3.330.0030.00313.66
7.3.320.0000.00513.77
7.3.310.0080.00215.30
7.3.300.0040.00315.30
7.3.290.0070.00415.34
7.3.280.0060.01016.03
7.3.270.0050.00715.54
7.3.260.0050.01016.75
7.3.250.0060.01015.72
7.3.240.0090.00315.25
7.3.230.0080.00515.19
7.3.220.0050.00313.80
7.3.210.0090.00515.35
7.3.200.0070.00916.60
7.3.190.0050.00715.37
7.3.180.0080.00515.35
7.3.170.0070.00715.35
7.3.160.0080.00315.34
7.3.150.0000.00613.75
7.3.140.0030.00313.71
7.3.130.0050.00814.33
7.3.120.0050.00915.31
7.3.110.0020.01215.18
7.3.100.0070.00515.25
7.3.90.0010.00915.27
7.3.80.0040.00915.29
7.3.70.0060.00515.18
7.3.60.0070.00415.27
7.3.50.0060.00515.20
7.3.40.0050.00815.29
7.3.30.0050.00515.18
7.3.20.0070.00616.36
7.3.10.0080.00516.41
7.3.00.0050.00816.29
7.2.340.0090.00413.55
7.2.330.0050.01315.38
7.2.320.0130.00415.42
7.2.310.0110.00715.20
7.2.300.0100.00615.22
7.2.290.0110.00615.44
7.2.280.0110.00313.83
7.2.270.0130.00013.77
7.2.260.0070.00914.49
7.2.250.0070.01014.54
7.2.240.0080.00815.29
7.2.230.0060.00715.28
7.2.220.0070.00815.37
7.2.210.0050.01015.37
7.2.200.0080.00615.33
7.2.190.0090.00715.42
7.2.180.0060.00915.31
7.2.170.0070.00815.38
7.2.160.0050.01015.39
7.2.150.0110.00416.61
7.2.140.0060.00816.60
7.2.130.0060.00716.58
7.2.120.0070.00716.65
7.2.110.0050.00816.66
7.2.100.0050.00816.63
7.2.90.0070.00716.65
7.2.80.0080.00716.68
7.2.70.0070.00716.69
7.2.60.0050.00916.75
7.2.50.0060.00816.74
7.2.40.0080.00716.58
7.2.30.0070.00816.75
7.2.20.0090.00616.56
7.2.10.0090.00816.63
7.2.00.0030.01317.46
7.1.330.0040.01015.84
7.1.320.0070.00715.92
7.1.310.0110.00315.77
7.1.300.0070.00615.85
7.1.290.0060.00815.89
7.1.280.0040.00915.77
7.1.270.0070.00615.87
7.1.260.0070.00515.84
7.1.250.0060.00815.74
7.1.240.0110.00315.15
7.1.230.0040.00715.13
7.1.220.0080.00515.33
7.1.210.0070.00915.24
7.1.200.0050.01115.47
7.1.190.0070.00415.24
7.1.180.0080.00715.32
7.1.170.0060.00815.26
7.1.160.0020.01015.22
7.1.150.0060.00815.27
7.1.140.0070.00415.22
7.1.130.0080.00515.16
7.1.120.0110.00515.15
7.1.110.0000.01215.36
7.1.100.0070.00516.23
7.1.90.0100.00315.19
7.1.80.0060.00715.26
7.1.70.0070.00515.85
7.1.60.0120.00516.62
7.1.50.0070.00915.83
7.1.40.0050.00715.29
7.1.30.0080.00515.17
7.1.20.0120.00115.25
7.1.10.0050.00815.24
7.1.00.0070.01417.67
7.0.330.0080.00614.95
7.0.320.0080.00615.15
7.0.310.0060.00515.06
7.0.300.0060.00514.89
7.0.290.0100.00415.12
7.0.280.0090.00415.10
7.0.270.0040.01014.97
7.0.260.0120.00314.98
7.0.250.0090.00515.17
7.0.240.0060.00515.14
7.0.230.0100.00215.13
7.0.220.0080.00415.14
7.0.210.0030.00715.08
7.0.200.0050.00715.67
7.0.190.0090.00515.01
7.0.180.0060.00615.17
7.0.170.0050.00915.13
7.0.160.0030.00915.09
7.0.150.0050.00714.92
7.0.140.0040.02817.46
7.0.130.0030.01215.26
7.0.120.0070.00514.86
7.0.110.0060.00615.03
7.0.100.0090.00615.02
7.0.90.0120.00114.98
7.0.80.0050.00715.10
7.0.70.0060.03117.33
7.0.60.0070.03117.33
7.0.50.0050.02517.48
7.0.40.0070.03116.23
7.0.30.0060.02316.15
7.0.20.0040.03016.16
7.0.10.0130.03016.08
7.0.00.0100.03016.20
5.6.400.0070.00613.85
5.6.390.0020.01214.12
5.6.380.0050.00514.04
5.6.370.0080.00813.90
5.6.360.0030.01013.96
5.6.350.0070.00514.09
5.6.340.0030.01013.97
5.6.330.0070.00713.89
5.6.320.0060.00714.02
5.6.310.0050.00814.12
5.6.300.0090.00513.98
5.6.290.0110.00314.12
5.6.280.0050.03016.36
5.6.270.0040.00813.98
5.6.260.0090.00313.82
5.6.250.0050.00913.85
5.6.240.0080.00614.10
5.6.230.0080.00413.80
5.6.220.0040.03616.22
5.6.210.0040.03316.24
5.6.200.0110.02916.43
5.6.190.0090.02816.42
5.6.180.0060.03116.42
5.6.170.0080.01816.50
5.6.160.0070.03016.44
5.6.150.0040.03316.40
5.6.140.0030.02516.46
5.6.130.0070.03116.46
5.6.120.0050.03116.53
5.6.110.0110.02516.33
5.6.100.0080.02816.35
5.6.90.0090.02516.36
5.6.80.0040.03016.12
5.6.70.0050.03016.13
5.6.60.0060.01616.19
5.6.50.0050.02916.04
5.6.40.0080.02116.06
5.6.30.0070.02816.24
5.6.20.0090.02616.10
5.6.10.0050.02916.28
5.6.00.0060.01816.24
5.5.380.0030.00914.09
5.5.370.0050.00714.06
5.5.360.0050.03516.21
5.5.350.0100.02316.27
5.5.340.0090.02916.34
5.5.330.0080.02516.31
5.5.320.0090.01516.35
5.5.310.0060.02916.27
5.5.300.0060.03016.16
5.5.290.0070.02916.29
5.5.280.0090.01416.34
5.5.270.0080.03216.27
5.5.260.0090.02816.24
5.5.250.0050.03216.39
5.5.240.0050.03316.15
5.5.230.0080.02616.02
5.5.220.0040.02616.03
5.5.210.0060.01815.99
5.5.200.0080.03115.96
5.5.190.0090.02816.08
5.5.180.0060.03215.89
5.5.170.0070.00313.90
5.5.160.0040.01815.94
5.5.150.0050.02015.96
5.5.140.0040.02615.93
5.5.130.0070.02915.95
5.5.120.0080.02015.98
5.5.110.0040.03516.03
5.5.100.0060.02816.06
5.5.90.0010.02816.07
5.5.80.0010.03216.10
5.5.70.0070.02516.01
5.5.60.0020.02616.09
5.5.50.0070.02715.91
5.5.40.0100.02216.08
5.5.30.0060.03016.01
5.5.20.0060.02716.02
5.5.10.0060.02816.06
5.5.00.0070.02716.01
5.4.450.0040.03114.71
5.4.440.0050.03114.73
5.4.430.0050.02314.69
5.4.420.0060.03014.68
5.4.410.0060.02614.76
5.4.400.0070.02614.63
5.4.390.0030.02414.59
5.4.380.0030.03114.55
5.4.370.0050.02814.39
5.4.360.0040.02514.50
5.4.350.0040.03014.58
5.4.340.0060.02014.44
5.4.330.0050.00712.16
5.4.320.0060.01814.57
5.4.310.0070.02014.66
5.4.300.0020.01714.44
5.4.290.0010.01714.69
5.4.280.0070.01814.58
5.4.270.0060.02014.50
5.4.260.0070.02814.43
5.4.250.0070.02714.51
5.4.240.0050.02914.54
5.4.230.0090.02714.46
5.4.220.0070.02414.59
5.4.210.0060.02814.60
5.4.200.0050.03214.47
5.4.190.0050.02914.42
5.4.180.0050.02514.39
5.4.170.0070.02414.47
5.4.160.0060.02214.39
5.4.150.0070.02314.56
5.4.140.0060.02913.61
5.4.130.0070.02213.67
5.4.120.0070.02513.64
5.4.110.0090.02213.71
5.4.100.0070.02813.61
5.4.90.0030.02613.77
5.4.80.0020.02113.69
5.4.70.0030.02913.69
5.4.60.0040.02713.70
5.4.50.0070.02613.79
5.4.40.0070.02613.59
5.4.30.0020.02613.54
5.4.20.0070.02613.66
5.4.10.0010.03313.70
5.4.00.0040.02813.26
5.3.290.0060.01913.15
5.3.280.0050.02613.03
5.3.270.0040.02213.09
5.3.260.0050.03013.13
5.3.250.0050.02213.17
5.3.240.0060.02713.05
5.3.230.0060.02613.13
5.3.220.0060.02613.02
5.3.210.0040.03013.11
5.3.200.0060.02413.06
5.3.190.0050.02513.00
5.3.180.0050.02313.31
5.3.170.0040.03213.18
5.3.160.0070.02713.16
5.3.150.0040.03113.24
5.3.140.0050.03013.06
5.3.130.0060.02613.16
5.3.120.0090.02213.09
5.3.110.0050.02713.09
5.3.100.0050.02513.12
5.3.90.0070.02113.21
5.3.80.0040.02013.02
5.3.70.0030.02813.08
5.3.60.0050.02313.04
5.3.50.0020.02313.05
5.3.40.0040.02713.15
5.3.30.0070.01913.04
5.3.20.0010.03113.00
5.3.10.0060.02712.93
5.3.00.0070.02412.86
5.2.170.0080.02713.74
5.2.160.0030.02713.61
5.2.150.0060.03313.72
5.2.140.0050.02613.71
5.2.130.0080.02813.73
5.2.120.0060.03113.76
5.2.110.0020.03413.71
5.2.100.0050.03013.76
5.2.90.0080.02913.64
5.2.80.0080.03213.62
5.2.70.0030.03113.54
5.2.60.0040.02913.51
5.2.50.0050.02813.62
5.2.40.0070.01813.75
5.2.30.0040.01913.67
5.2.20.0060.02413.67
5.2.10.0060.03113.64
5.2.00.0010.02213.54
5.1.60.0050.02413.21
5.1.50.0000.02713.22
5.1.40.0080.02313.29
5.1.30.0090.02313.35
5.1.20.0070.02813.18
5.1.10.0060.02813.28
5.1.00.0050.02513.20
5.0.50.0040.01612.74
5.0.40.0030.02112.74
5.0.30.0040.03112.74
5.0.20.0020.02812.74
5.0.10.0010.02612.74
5.0.00.0010.03612.74
4.4.90.0000.02112.74
4.4.80.0040.01512.74
4.4.70.0020.01512.74
4.4.60.0020.01512.74
4.4.50.0020.02012.74
4.4.40.0030.02412.74
4.4.30.0030.01512.74
4.4.20.0010.01912.74
4.4.10.0000.01212.74
4.4.00.0040.02512.74
4.3.110.0030.01812.74
4.3.100.0000.01512.74
4.3.90.0040.01512.74
4.3.80.0000.02412.74
4.3.70.0010.01612.74
4.3.60.0000.02012.74
4.3.50.0050.01212.74
4.3.40.0050.02212.74
4.3.30.0020.01212.74
4.3.20.0010.01412.74
4.3.10.0010.01812.74
4.3.00.0020.01512.74

preferences:
49.47 ms | 401 KiB | 5 Q