3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DOMExtract extends DOMDocument { private $source; private $dom; public function __construct() { libxml_use_internal_errors(true); $this->preserveWhiteSpace = false; $this->strictErrorChecking = false; $this->formatOutput = true; } public function setSource($source) { $this->source = $source; return $this; } public function getInnerHTML($tag, $id=null, $nodeValue = false) { if (empty($this->source)) { throw new Exception('Error: Missing $this->source, use setSource() first'); } $this->loadHTML($this->source); $tmp = $this->getElementsByTagName($tag); $ret = null; foreach ($tmp as $v) { if ($id !== null) { $attr = explode('=', $id); if ($v->getAttribute($attr[0]) == $attr[1]) { if ($nodeValue == true) { $ret .= trim($v->nodeValue); } else { $ret .= $this->innerHTML($v); } } } else { if ($nodeValue == true) { $ret .= trim($v->nodeValue); } else{ $ret .= $this->innerHTML($v); } } } return $ret; } public function innerHTML($dom) { $ret = ""; foreach ($dom->childNodes as $v) { $tmp = new DOMDocument(); $tmp->appendChild($tmp->importNode($v, true)); $ret .= trim($tmp->saveHTML()); } return $ret; } } $html = ' <h3>HTML Table Example</h3> <div> <table id="customers"> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> <tr> <td>Ernst Handel</td> <td>Roland Mendel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td> <td>Helen Bennett</td> <td>UK</td> </tr> <tr> <td>Laughing Bacchus Winecellars</td> <td>Yoshi Tannamuri</td> <td>Canada</td> </tr> <tr> <td>Magazzini Alimentari Riuniti</td> <td>Giovanni Rovelli</td> <td>Italy</td> </tr> </table> </div>'; $dom = new DOMExtract(); $dom->setSource($html); echo ' <table cellspacing="0" cellpadding="3" border="0" width="100%">', //match and return only tables inner content with id=customers $dom->getInnerHTML('table', 'id=customers'), //match all tables inner content //$dom->getInnerHTML('table'), '</table>';

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.4.140.0130.00818.01
8.4.130.0140.00718.14
8.4.120.0120.00922.79
8.4.110.0120.00919.07
8.4.100.0130.01018.04
8.4.90.0070.01418.92
8.4.80.0130.00818.17
8.4.70.0150.00618.01
8.4.60.0080.00318.95
8.4.50.0120.01018.03
8.4.40.0070.00421.08
8.4.30.0100.00617.91
8.4.20.0120.00919.79
8.4.10.0070.00419.57
8.3.270.0130.00716.81
8.3.260.0130.00817.01
8.3.250.0100.00918.94
8.3.240.0110.00916.94
8.3.230.0110.01016.92
8.3.220.0080.01017.47
8.3.210.0100.00917.09
8.3.200.0070.00417.25
8.3.190.0060.00319.30
8.3.180.0100.00916.99
8.3.170.0040.01617.61
8.3.160.0160.00316.63
8.3.150.0090.00620.90
8.3.140.0060.00319.10
8.3.130.0040.00418.72
8.3.120.0130.00719.28
8.3.110.0040.00420.94
8.3.100.0070.00324.06
8.3.90.0060.01226.77
8.3.80.0030.00617.97
8.3.70.0070.01118.54
8.3.60.0130.00618.55
8.3.50.0060.01017.71
8.3.40.0090.00619.07
8.3.30.0120.00318.92
8.3.20.0030.00520.29
8.3.10.0000.00822.15
8.3.00.0040.00423.78
8.2.290.0110.00920.63
8.2.280.0080.01118.57
8.2.270.0060.01217.56
8.2.260.0090.00316.74
8.2.250.0080.00016.84
8.2.240.0030.00619.37
8.2.230.0130.00622.58
8.2.220.0060.00337.54
8.2.210.0030.00626.77
8.2.200.0030.00718.36
8.2.190.0060.00916.88
8.2.180.0060.01018.79
8.2.170.0190.00622.96
8.2.160.0100.00320.64
8.2.150.0000.00824.18
8.2.140.0090.00024.66
8.2.130.0040.00421.43
8.2.120.0090.00026.35
8.2.110.0030.00720.77
8.2.100.0000.01118.40
8.2.90.0000.00818.36
8.2.80.0050.00318.18
8.2.70.0030.00618.05
8.2.60.0050.00318.47
8.2.50.0050.00318.10
8.2.40.0050.00320.68
8.2.30.0040.00419.57
8.2.20.0030.00518.41
8.2.10.0040.00418.36
8.2.00.0050.00218.32
8.1.330.0080.00422.46
8.1.320.0110.00916.18
8.1.310.0110.00818.71
8.1.300.0070.00318.44
8.1.290.0090.00330.84
8.1.280.0150.00625.92
8.1.270.0060.00320.85
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00621.19
8.1.230.0040.00821.26
8.1.220.0060.00318.13
8.1.210.0040.00418.90
8.1.200.0070.00317.60
8.1.190.0000.00917.60
8.1.180.0000.00818.10
8.1.170.0060.00318.99
8.1.160.0060.00319.27
8.1.150.0040.00419.11
8.1.140.0000.00719.27
8.1.130.0040.00419.22
8.1.120.0000.00817.68
8.1.110.0040.00417.72
8.1.100.0040.00417.71
8.1.90.0040.00417.59
8.1.80.0050.00317.70
8.1.70.0000.00717.72
8.1.60.0000.00817.92
8.1.50.0050.00317.73
8.1.40.0030.00517.77
8.1.30.0050.00517.89
8.1.20.0020.00517.91
8.1.10.0060.00617.75
8.1.00.0030.00617.85
8.0.300.0040.00419.81
8.0.290.0050.00317.00
8.0.280.0050.00318.64
8.0.270.0000.00817.21
8.0.260.0000.00717.16
8.0.250.0040.00417.22
8.0.240.0000.00717.23
8.0.230.0060.00317.24
8.0.220.0000.00717.17
8.0.210.0040.00417.12
8.0.200.0040.00417.26
8.0.190.0000.00917.16
8.0.180.0040.00417.17
8.0.170.0040.00417.13
8.0.160.0000.00717.24
8.0.150.0000.00717.12
8.0.140.0000.00717.10
8.0.130.0060.00013.59
8.0.120.0030.00617.11
8.0.110.0030.00517.20
8.0.100.0040.00417.05
8.0.90.0000.00816.98
8.0.80.0110.00717.23
8.0.70.0080.00017.25
8.0.60.0050.00317.29
8.0.50.0000.00817.26
8.0.30.0110.00617.31
8.0.20.0140.00617.41
8.0.10.0050.00317.23
8.0.00.0130.01017.10
7.4.330.0000.00515.55
7.4.320.0030.00316.82
7.4.300.0000.00616.81
7.4.290.0040.00416.75
7.4.280.0070.00016.95
7.4.270.0000.00716.98
7.4.260.0040.00416.73
7.4.250.0030.00516.80
7.4.240.0000.00716.86
7.4.230.0050.00316.89
7.4.220.0050.00217.04
7.4.210.0130.00316.83
7.4.200.0000.00816.86
7.4.160.0120.00616.64
7.4.150.0100.00717.40
7.4.140.0090.01217.86
7.4.130.0120.00616.71
7.4.120.0100.00816.83
7.4.110.0100.01417.01
7.4.100.0090.00916.78
7.4.90.0070.01016.73
7.4.80.0090.00919.39
7.4.70.0070.01116.68
7.4.60.0080.00816.79
7.4.50.0070.00516.61
7.4.40.0160.00616.62
7.4.30.0080.00816.90
7.4.00.0100.00315.17
7.3.330.0000.00613.66
7.3.320.0030.00313.57
7.3.310.0000.00716.56
7.3.300.0030.00316.70
7.3.290.0080.01016.62
7.3.280.0070.01416.67
7.3.270.0090.00917.40
7.3.260.0120.00516.82
7.3.250.0120.00616.59
7.3.240.0090.01116.88
7.3.230.0180.00016.74
7.3.210.0060.01216.80
7.3.200.0030.01916.85
7.3.190.0110.00716.61
7.3.180.0100.00616.66
7.3.170.0060.01016.72
7.3.160.0100.01016.80
7.2.330.0090.00917.00
7.2.320.0090.01216.81
7.2.310.0130.00616.91
7.2.300.0060.01617.08
7.2.290.0070.01017.14
7.2.60.0030.01016.88
7.2.00.0100.00819.72
7.1.200.0000.01115.75
7.1.120.0100.01118.65
7.1.110.0090.00918.39
7.1.100.0140.00718.11
7.1.90.0000.01918.51
7.1.80.0040.01118.21
7.1.70.0030.00917.14
7.1.60.0270.00735.12
7.1.50.0180.02234.99
7.1.40.0170.01434.47
7.1.30.0190.01934.60
7.1.20.0130.01734.68
7.1.10.0050.01316.92
7.1.00.0070.01016.78

preferences:
140.19 ms | 403 KiB | 5 Q