3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOF <div id="nav"> <ul id="someID"> <li><a href="/poker/?ca=v"> THIS </a></li> </ul> </div> EOF; function extractNodeValue($query, $xPath, $attribute = null) { $node = $xPath->query("//{$query}")->item(0); if (!$node) { return null; } return $attribute ? $node->getAttribute($attribute) : $node->nodeValue; } $document = new DOMDocument(); $document->loadHTML($html); $xPath = new DOMXpath($document); $name = extractNodeValue('/a[@href="/poker/?ca=v"]/text()', $xPath); var_dump($name);

preferences:
48.39 ms | 402 KiB | 5 Q