3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA This is a link <a href="https://stackoverflow.com/">SO</a> and this is <a href="http://test.test">unsubscribe</a> and another and this is <a href="http://test.test">UnSubScribe</a>. DATA; $dom = new DomDocument(); $dom->loadHTML($data); $xpath = new DOMXPath($dom); $query = "//a[contains(translate(., 'UNSUBSCRIBE', 'unsubscribe'),'unsubscribe')]"; $anchors = $xpath->query($query); foreach ($anchors as $a) { echo sprintf("%s: %s" . PHP_EOL, $a->nodeValue, $a->getAttribute("href") ); }

preferences:
31.74 ms | 404 KiB | 5 Q