3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!doctype html> <html> <head> <title>test</title> </head> <body> <a id="1"> <b>value1</b> <b>value2</b> </a> <a id="2"> <b>value1</b> </a> </body> </html>'; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXpath($doc); $nodes = $xpath->query("//b[contains(., 'value1')] | //b[contains(., 'value2')]"); $parent_id = $nodes->item(0)->parentNode->getAttribute("id"); echo $parent_id;
Output for git.master, git.master_jit, rfc.property-hooks
1

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
119.45 ms | 405 KiB | 5 Q