<?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") ); }
You have javascript disabled. You will not be able to edit any code.