3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = <<<HTML <div class="directions"> <div class="left">ä,ö,ü</div> <div class="right">right</div> </div> HTML; libxml_use_internal_errors(true); libxml_disable_entity_loader(true); $html = new DOMDocument(); $html->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); $xpath = new DOMXpath($html); $result = $xpath->query('//div[contains(@class, "left")]'); echo $result[0]->textContent;

preferences:
24.81 ms | 406 KiB | 5 Q