find and replace keywords by hyperlinks in an html fragment, via php dom
That’s somewhat tricky, but you could do it this way: $html = <<< HTML <div><p>The CEO of the Dexia bank <em>has</em> just decided to retire.</p></div> HTML; I’ve added an emphasis element just to illustrate that it works with inline elements too. Setup $dom = new DOMDocument; $dom->formatOutput = TRUE; $dom->loadXML($html); $xpath = new DOMXPath($dom); $nodes … Read more