3v4l.org

run code in 300+ PHP versions simultaneously
<?php $XML = ' <html> <h1>Hello</h1> <ol> <li>test (no id)</li> <li xml:id="i2">test i2</li> </ol> </html> '; $doc = new DOMDocument; $doc->loadXML($XML); $xpath = new DOMXpath($doc); // get the ol $olNode = $xpath->evaluate('//ol[1]', NULL, FALSE)->item(0); // append a new list item $olNode->appendChild($liNode = $doc->createElement('li')); $liNode->appendChild($doc->createTextNode('test i3')); $liNode->setAttribute('xml:id', 'i3'); // show new DOM state print $doc->saveXML(); // insert a new list item before the others $olNode->insertBefore($liNode = $doc->createElement('li'), $olNode->firstChild); $liNode->appendChild($doc->createTextNode('test i0')); $liNode->setAttribute('xml:id', 'i0'); // show new DOM state print $doc->saveXML(); // fetch the li nodes without an xml:id $nodes = $xpath->evaluate('//ol/li[not(@xml:id)]', NULL, FALSE); // and remove them in reverse order for ($i = $nodes->length - 1; $i >= 0; --$i) { $nodes->item($i)->parentNode->removeChild($nodes->item($i)); } // show new DOM state print $doc->saveXML(); // replace the li[@xml:id'i2'] with a new node $liNode = $doc->getElementById('i2'); $followingNode = $liNode->nextSibling; $odNode = $liNode->parentNode; $olNode->removeChild($liNode); $olNode->insertBefore($liNode = $doc->createElement('li'), $followingNode); $liNode->appendChild($doc->createTextNode('test i2 replaced')); $liNode->setAttribute('xml:id', 'i2'); // show new DOM state print $doc->saveXML(); // NOT REFRESHING!?! var_dump($doc->getElementById('i2')); // object(DOMElement)#5 (0) { } li //CAN_NOT_doMORESomeChange($doc); $doc->loadXML($doc->saveXML()); // only way to refresh? print $doc->getElementById('i2')->tagName; //OK, is there // be ware that the xpath still uses the old document var_dump($xpath->document === $doc);

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.40.0160.00019.34
8.3.30.0100.00618.98
8.3.20.0030.00519.16
8.3.10.0040.00419.15
8.3.00.0060.00319.63
8.2.170.0040.01222.96
8.2.160.0040.01219.38
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0060.00319.94
8.2.110.0090.00922.82
8.2.100.0040.00818.43
8.2.90.0080.00019.61
8.2.80.0030.00517.97
8.2.70.0040.00418.13
8.2.60.0030.00618.43
8.2.50.0030.00618.10
8.2.40.0050.00318.78
8.2.30.0070.00318.15
8.2.20.0050.00518.09
8.2.10.0040.00418.14
8.2.00.0060.00318.26
8.1.270.0060.00323.99
8.1.260.0040.00426.35
8.1.250.0000.00928.09
8.1.240.0030.00719.71
8.1.230.0070.00717.89
8.1.220.0090.00018.14
8.1.210.0000.00818.77
8.1.200.0030.00717.85
8.1.190.0030.00517.73
8.1.180.0000.00918.10
8.1.170.0000.00819.05
8.1.160.0050.00319.58
8.1.150.0040.00419.10
8.1.140.0000.00817.90
8.1.130.0050.00218.03
8.1.120.0040.00417.89
8.1.110.0040.00417.77
8.1.100.0080.00017.74
8.1.90.0030.00517.86
8.1.80.0040.00418.05
8.1.70.0040.00418.00
8.1.60.0030.00618.11
8.1.50.0000.00817.74
8.1.40.0030.00617.93
8.1.30.0030.00618.03
8.1.20.0080.00417.84
8.1.10.0040.00418.11
8.1.00.0030.00618.14
8.0.300.0030.00518.77
8.0.290.0080.00317.13
8.0.280.0040.00418.87
8.0.270.0030.00517.65
8.0.260.0000.00717.19
8.0.250.0040.00417.45
8.0.240.0050.00317.36
8.0.230.0030.00617.42
8.0.220.0060.00317.16
8.0.210.0040.00417.20
8.0.200.0100.00017.44
8.0.190.0000.00717.47
8.0.180.0040.00417.42
8.0.170.0100.00017.42
8.0.160.0040.00417.10
8.0.150.0000.00917.30
8.0.140.0050.00317.13
8.0.130.0030.00313.71
8.0.120.0070.00417.20
8.0.110.0040.00417.18
8.0.100.0000.00717.20
8.0.90.0000.00817.16
8.0.80.0130.00317.29
8.0.70.0040.00417.14
8.0.60.0000.00917.13
8.0.50.0030.00517.37
8.0.30.0120.00817.57
8.0.20.0070.01417.60
8.0.10.0000.00817.35
8.0.00.0100.01217.13
7.4.330.0050.00013.59
7.4.320.0000.00617.10
7.4.300.0030.00317.09
7.4.290.0030.00717.09
7.4.280.0030.00616.89
7.4.270.0040.00416.94
7.4.260.0000.00613.79
7.4.250.0080.00016.91
7.4.240.0040.00417.00
7.4.230.0000.00816.92
7.4.220.0080.01217.12
7.4.210.0080.01217.21
7.4.200.0030.00517.21
7.4.190.0080.00017.17
7.4.160.0130.00517.09
7.4.150.0130.00817.08
7.4.140.0080.01317.86
7.4.130.0100.01017.01
7.4.120.0110.00716.95
7.4.110.0030.01617.04
7.4.100.0030.01517.01
7.4.90.0120.01516.96
7.4.80.0090.01219.39
7.4.70.0190.00016.88
7.4.60.0110.00716.96
7.4.50.0060.00317.06
7.4.40.0060.01016.66
7.4.30.0090.00917.06
7.4.10.0070.01315.54
7.4.00.0060.01015.22
7.3.330.0000.00713.73
7.3.320.0050.00013.69
7.3.310.0050.00216.93
7.3.300.0000.00716.82
7.3.290.0070.00916.83
7.3.280.0030.01316.81
7.3.270.0140.00317.00
7.3.260.0120.00616.88
7.3.240.0110.00717.09
7.3.230.0090.01016.87
7.3.210.0080.01116.98
7.3.200.0030.01616.89
7.3.190.0070.01116.92
7.3.180.0070.01116.84
7.3.170.0120.00816.78
7.3.160.0070.01016.88
7.3.130.0060.01315.34
7.3.120.0070.01115.21
7.3.110.0140.00515.27
7.3.100.0070.01015.31
7.3.90.0150.00415.16
7.3.80.0010.01315.04
7.3.70.0070.01015.18
7.3.60.0070.01015.02
7.3.50.0040.01115.05
7.3.40.0060.00515.11
7.3.30.0060.00715.08
7.3.20.0050.00816.83
7.3.10.0020.00916.92
7.3.00.0070.00916.81
7.2.330.0130.00517.00
7.2.320.0090.00917.25
7.2.310.0000.02017.08
7.2.300.0150.00417.36
7.2.290.0130.01016.93
7.2.260.0060.01315.49
7.2.250.0040.01515.39
7.2.240.0070.01215.43
7.2.230.0040.01315.42
7.2.220.0070.01015.33
7.2.210.0070.01115.27
7.2.200.0080.00815.31
7.2.190.0040.01015.32
7.2.180.0110.00515.30
7.2.170.0090.00815.24
7.2.160.0000.01415.58
7.2.150.0030.00917.20
7.2.140.0060.00916.93
7.2.130.0040.01117.07
7.2.120.0070.01017.37
7.2.110.0100.00717.19
7.2.100.0030.00616.92
7.2.90.0030.01017.16
7.2.80.0030.01317.12
7.2.70.0070.00717.13
7.2.60.0030.01017.15
7.2.50.0080.00617.32
7.2.40.0060.01117.31
7.2.30.0040.01117.33
7.2.20.0110.00017.25
7.2.10.0090.00617.36
7.2.00.0020.01418.25
7.1.330.0030.01116.09
7.1.320.0040.01316.06
7.1.310.0030.00816.11
7.1.300.0050.00815.97
7.1.290.0060.00716.00
7.1.280.0020.01115.86
7.1.270.0050.00816.04
7.1.260.0110.00315.97
7.1.250.0070.00715.96
7.1.240.0000.01315.91
7.1.230.0070.00716.03
7.1.220.0060.00616.01
7.1.210.0040.01216.07
7.1.200.0030.00915.89
7.1.190.0030.00716.14
7.1.180.0000.00815.95
7.1.170.0060.00916.13
7.1.160.0040.00715.95
7.1.150.0000.01616.09
7.1.140.0070.00716.09
7.1.130.0040.00416.09
7.1.120.0040.00415.77
7.1.110.0110.00416.06
7.1.100.0050.00617.25
7.1.90.0070.00716.06
7.1.80.0080.00815.97
7.1.70.0050.00716.75
7.1.60.0080.00817.66
7.1.50.0090.01016.44
7.1.40.0080.00416.14
7.1.30.0060.00915.91
7.1.20.0110.00316.20
7.1.10.0060.00916.07
7.1.00.0090.03519.36
7.0.330.0030.01015.76
7.0.320.0030.00915.68
7.0.310.0100.00315.63
7.0.300.0070.01315.57
7.0.290.0060.00615.52
7.0.280.0030.01315.51
7.0.270.0040.00415.43
7.0.260.0030.01015.71
7.0.250.0060.00615.73
7.0.240.0090.00015.68
7.0.230.0090.00315.73
7.0.220.0100.00315.59
7.0.210.0090.00615.51
7.0.200.0060.00516.43
7.0.190.0100.00315.94
7.0.180.0040.01115.60
7.0.170.0040.01215.50
7.0.160.0030.01015.55
7.0.150.0060.00815.60
7.0.140.0050.04018.95
7.0.130.0030.01415.72
7.0.120.0020.03518.93
7.0.110.0040.00415.55
7.0.100.0110.00415.54
7.0.90.0070.00415.51
7.0.80.0040.00815.64
7.0.70.0030.00615.59
7.0.60.0030.02817.91
7.0.50.0070.02016.79
7.0.40.0060.02115.89
7.0.30.0080.04415.87
7.0.20.0100.04215.82
7.0.10.0060.04015.81
7.0.00.0050.04415.76
5.6.400.0040.00714.62
5.6.390.0030.01314.51
5.6.380.0080.01114.79
5.6.370.0130.00014.88
5.6.360.0040.01114.30
5.6.350.0030.01014.53
5.6.340.0030.01014.58
5.6.330.0040.01114.23
5.6.320.0090.00614.67
5.6.310.0060.00614.53
5.6.300.0120.00414.73
5.6.290.0030.00614.38
5.6.280.0030.01214.67
5.6.270.0070.00314.91
5.6.260.0070.00714.59
5.6.250.0060.01014.59
5.6.240.0090.00614.52
5.6.230.0060.00914.70
5.6.220.0060.00614.49
5.6.210.0120.03517.90
5.6.200.0050.02516.50
5.6.190.0030.02316.46
5.6.180.0020.03216.47
5.6.170.0070.02516.54
5.6.160.0070.04016.39
5.6.150.0050.03516.49
5.6.140.0090.03716.49
5.6.130.0090.03216.37
5.6.120.0130.03816.46
5.6.110.0020.03216.47
5.6.100.0060.04416.60
5.6.90.0060.03416.46
5.6.80.0090.04416.23
5.6.70.0120.03816.13
5.6.60.0080.02116.21
5.6.50.0080.02516.24
5.6.40.0110.02416.10
5.6.30.0070.04016.14
5.6.20.0120.03816.00
5.6.10.0080.04416.11
5.6.00.0030.02816.09
5.5.380.0060.00914.60
5.5.370.0090.00614.28
5.5.360.0030.01214.61
5.5.350.0140.04417.72
5.5.340.0030.02516.37
5.5.330.0040.02216.46
5.5.320.0070.03416.31
5.5.310.0060.04816.37
5.5.300.0050.04516.37
5.5.290.0060.02316.43
5.5.280.0120.03716.28
5.5.270.0100.02016.34
5.5.260.0060.02216.30
5.5.250.0050.04116.19
5.5.240.0030.03916.03
5.5.230.0030.02615.93
5.5.220.0020.02716.02
5.5.210.0120.02515.83
5.5.200.0090.04216.13
5.5.190.0070.02515.99
5.5.180.0050.02715.83
5.5.170.0030.00814.21
5.5.160.0100.03816.06
5.5.150.0100.02016.01
5.5.140.0040.02515.97
5.5.130.0070.04315.92
5.5.120.0040.03916.03
5.5.110.0060.03716.12
5.5.100.0070.02115.90
5.5.90.0060.02316.02
5.5.80.0050.04415.96
5.5.70.0030.04516.01
5.5.60.0110.03816.02
5.5.50.0030.04216.02
5.5.40.0070.03715.80
5.5.30.0080.04315.98
5.5.20.0050.03515.89
5.5.10.0090.03415.99
5.5.00.0110.04015.93
5.4.450.0050.03416.59
5.4.440.0030.03716.56
5.4.430.0060.03316.58
5.4.420.0090.03616.63
5.4.410.0100.02716.49
5.4.400.0070.03916.48
5.4.390.0020.04516.46
5.4.380.0040.02416.43
5.4.370.0050.02116.47
5.4.360.0020.04516.46
5.4.350.0030.03916.37
5.4.340.0030.03316.41
5.4.330.0050.00313.58
5.4.320.0070.03216.39
5.4.310.0040.02616.32
5.4.300.0020.02716.47
5.4.290.0050.02716.39
5.4.280.0030.04516.46
5.4.270.0080.03716.37
5.4.260.0080.02516.37
5.4.250.0100.03716.36
5.4.240.0100.03716.38
5.4.230.0080.03616.45
5.4.220.0050.04016.41
5.4.210.0070.02516.48
5.4.200.0130.03716.36
5.4.190.0060.03616.46
5.4.180.0120.03016.43
5.4.170.0020.02816.49
5.4.160.0080.03816.40
5.4.150.0030.03616.31
5.4.140.0020.04315.09
5.4.130.0030.02315.07
5.4.120.0050.03115.12
5.4.110.0050.02515.03
5.4.100.0030.02715.16
5.4.90.0030.02215.14
5.4.80.0000.04215.02
5.4.70.0090.03315.07
5.4.60.0090.03515.15
5.4.50.0070.04015.07
5.4.40.0050.03215.03
5.4.30.0070.02315.07
5.4.20.0040.02515.05
5.4.10.0030.03015.04
5.4.00.0080.03314.83
5.3.290.0040.02914.26
5.3.280.0030.03014.13
5.3.270.0030.04314.16
5.3.260.0030.03114.18
5.3.250.0030.04314.12
5.3.240.0070.01814.15
5.3.230.0040.03214.20
5.3.220.0030.04114.12
5.3.210.0080.03714.12
5.3.200.0040.02014.18
5.3.190.0050.03714.16
5.3.180.0020.02614.19
5.3.170.0020.03014.19
5.3.160.0080.04314.16
5.3.150.0050.04014.16
5.3.140.0030.03114.19
5.3.130.0030.02414.16
5.3.120.0100.01814.19
5.3.110.0070.04214.11
5.3.100.0020.03213.84
5.3.90.0060.02213.91
5.3.80.0050.03813.90
5.3.70.0070.02713.88
5.3.60.0040.03713.88
5.3.50.0050.04313.79
5.3.40.0030.03113.78
5.3.30.0040.02413.85
5.3.20.0050.02213.71
5.3.10.0090.03513.71
5.3.00.0000.04213.67
5.2.170.0070.02711.34
5.2.160.0030.04011.31
5.2.150.0100.05011.31
5.2.140.0030.03011.20
5.2.130.0070.06011.29
5.2.120.0100.06011.17
5.2.110.0070.06011.29
5.2.100.0000.05011.26
5.2.90.0000.04311.11
5.2.80.0070.06011.37
5.2.70.0030.06011.41
5.2.60.0030.06711.20
5.2.50.0030.04311.21
5.2.40.0030.04011.28
5.2.30.0030.06711.25
5.2.20.0070.06010.98
5.2.10.0030.05710.94
5.2.00.0070.06010.96
5.1.60.0000.05710.27
5.1.50.0000.05310.21
5.1.40.0100.03310.08
5.1.30.0030.04710.52
5.1.20.0100.04710.58
5.1.10.0070.04010.32
5.1.00.0070.02310.13
5.0.50.0000.0238.76
5.0.40.0030.0478.48
5.0.30.0000.0478.41
5.0.20.0000.0478.38
5.0.10.0000.0308.45
5.0.00.0070.0608.40
4.4.90.0000.0237.55
4.4.80.0070.0307.55
4.4.70.0000.0377.55
4.4.60.0000.0277.55
4.4.50.0030.0277.55
4.4.40.0030.0537.55
4.4.30.0000.0377.55
4.4.20.0000.0377.55
4.4.10.0000.0177.55
4.4.00.0000.0607.55
4.3.110.0000.0407.55
4.3.100.0070.0307.55
4.3.90.0030.0337.55
4.3.80.0070.0277.55
4.3.70.0070.0307.55
4.3.60.0000.0337.55
4.3.50.0030.0207.55
4.3.40.0030.0507.55
4.3.30.0000.0337.55
4.3.20.0000.0377.55
4.3.10.0000.0407.55
4.3.00.0030.0207.55

preferences:
45.41 ms | 400 KiB | 5 Q