I've got a large database of text I want to add relevant links to. I'm not sure how to avoid nested links. Any tips?
<?php
$text = "A paragraph with a keyword phrase in it, and a keyword occurs once again, and a <a href=#>keyword phrase</a> that has a link already.";
$find = array("keyword phrase", "keyword");
$replace = array("<a href=#>keyword phrase</a>","<a href=#>keyword</a>");
echo str_replace($find, $replace, $text);
?>
<h1>Result:</h1>
A paragraph with a <a href=#><a href=#>keyword</a> phrase</a> in it, and a <a href=#>keyword</a> occurs once again, and a <a href=#><a href=#><a href=#>keyword</a> phrase</a></a> that has a link already.