title: Change specific words into links within HTML using PHP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4003031/how-to-replace-text-urls-and-exclude-urls-in-html-tags">How to replace text URLs and exclude URLs in HTML tags?</a>  </p>
  </blockquote>
  
  
  
  <p>Given some HTML markup, I want to add  links around specific words in the text.  But I don't want to affect attributes, or non-visble words.  Nor do I want to end up double linking words (eg. <code><code>&lt;a href="#"&gt;I went to &lt;a href="#"&gt;China&lt;/a&gt;&lt;/a&gt;</code></code>.</p>
  
  <p><strong>Sample</strong></p>
  
  <pre><code>&lt;h2&gt;We are speaking English&lt;/h2&gt;
  &lt;p&gt;When speaking to somebody you can use our handy &lt;a href="/speaking-guide.html"&gt;
      speaking guide&lt;/a&gt;.&lt;/p&gt;
  </code></pre>
  
  <p><strong>Ideal result on linkng 'speaking'</strong></p>
  
  <pre><code>&lt;h2&gt;We are &lt;a&gt;speaking&lt;/a&gt; English&lt;/h2&gt;
  &lt;p&gt;When &lt;a&gt;speaking&lt;/a&gt; to somebody you can use our handy &lt;a href="/speaking-guide.html"&gt;
      speaking guide&lt;/a&gt;.&lt;/p&gt;
  </code></pre>
  
  <p>Note that the href of the existing link has not been changed, nor has the word speaking within the pre-existing link.</p>
  
  <p>What is the proper way to do this?  If not using regex then with what?</p>