3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = ' <table id="myTable"> <tbody> <tr> <td>08/20/18</td> <td> <a href="https://example.com/1a">Text 1 A</a> </td> <td> <a href="https://example.com/1b">Test 1 B</a> </td> </tr> <tr> <td>08/21/18</td> <td> <a href="https://example.com/2a">Text 2 A</a> </td> <td> <a href="https://example.com/2b">Test 2 B</a> </td> </tr> </tbody> </table> '; // setup DOMDocument $doc = new DOMDocument(); $doc->loadHTML('<?xml encoding="utf-8" ?>' . $html); $xpath = new DOMXPath($doc); // target table using xpath $results = $xpath->query("//*[@id='myTable']"); if ($results->length > 0) { // Results object print_r($results->item(0)); // Results nodeValue print_r($results->item(0)->nodeValue); }
Output for 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
DOMElement Object ( [tagName] => table [className] => [id] => myTable [schemaTypeInfo] => [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 1 [previousElementSibling] => [nextElementSibling] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [parentElement] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => (object value omitted) [attributes] => (object value omitted) [isConnected] => 1 [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.0 - 8.3.28
DOMElement Object ( [schemaTypeInfo] => [tagName] => table [className] => [id] => myTable [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 1 [previousElementSibling] => [nextElementSibling] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [parentElement] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => (object value omitted) [attributes] => (object value omitted) [isConnected] => 1 [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 8.1.22 - 8.1.33, 8.2.9 - 8.2.29
DOMElement Object ( [schemaTypeInfo] => [tagName] => table [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 1 [previousElementSibling] => [nextElementSibling] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => (object value omitted) [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 8.1.0 - 8.1.21, 8.2.0 - 8.2.8
DOMElement Object ( [schemaTypeInfo] => [tagName] => table [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 1 [previousElementSibling] => [nextElementSibling] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 8.0.30
DOMElement Object ( [tagName] => table [schemaTypeInfo] => [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 1 [previousElementSibling] => [nextElementSibling] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => (object value omitted) [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 8.0.0 - 8.0.29
DOMElement Object ( [tagName] => table [schemaTypeInfo] => [firstElementChild] => (object value omitted) [lastElementChild] => (object value omitted) [childElementCount] => 1 [previousElementSibling] => [nextElementSibling] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 7.1.2 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
DOMElement Object ( [tagName] => table [schemaTypeInfo] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B
Output for 7.1.0 - 7.1.1
DOMElement Object ( [tagName] => table [schemaTypeInfo] => [nodeName] => table [nodeValue] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => table [baseURI] => [textContent] => 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B ) 08/20/18 Text 1 A Test 1 B 08/21/18 Text 2 A Test 2 B

preferences:
182.87 ms | 428 KiB | 5 Q