Using PHP how do I replace text in HTML but ignore attributes and existing tags?
I have a block of html code as a string in PHP and I want to replace certain text and phrases with links. The problem is some of the phrases I want to replace already appear in tag attributes or existing links so a simple str_replace breaks the HTML.