3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php header('Content-type: text/plain; charset=utf-8'); error_reporting(0); ////////////////////////////////////////// $urlParams = explode('/', $_SERVER['REQUEST_URI']); $word = $urlParams[2]; $url = "http://www.oxfordlearnersdictionaries.com/definition/english/comfortable"; ////////////////////////////////////////// $dom = new DOMDocument; $dom->loadHTMLFile($url); $xpath = new DOMXPath($dom); $qx = '//*[@class="pron-gs ei-g"]/span[@class="pron-g"]'; $nodes = $xpath->query($qx); /* Set HTTP response header to plain text for debugging output */ header("Content-type: text/plain"); /* Traverse the DOMNodeList object to output each DomNode's nodeValue */ foreach ($nodes as $i => $node) { echo "\n\n", "Node($i): ", $node->C14N(), "\n"; } //*[@id="ceremony__10"]/span[2] //*[@id="tab3"]/div/div[1]/strong/span //$rqx5 = '//div[@class="tudich"]/div[@class="candich"]'; // tieu de co han tu //$rqx5 = '//div[@class="tudich"]/div[@class="kqdich"]/div[@class="nddich"]/span'; // khong co han tu //$rqx5 = '//div[@class="tudich"]/div[@class="kqdich"]/div[@class="nddich"]/strong[1]'; // nghia //$result = array(); // foreach ($nodes as $i => $node) { // $child = $xpath->query($rqx5, $node)->item(0); // if (!empty($child)) { // echo PHP_EOL . $i ." = ". $child->nodeValue; // } // else { // echo PHP_EOL . $i ." = ". ":)"; // } // } ?>
Output for 5.3.19 - 7.2.0