title: How to determine if text string appears as a child of a named html tag
body: <p>In the doReplace function below, how would I determine if the instance of $keyword is not a child of any of an array of named html tags (h1, h2, h3, h4, h5, h6, b, u, i, etc) from the replacement point where the keyword appears in the content? I don't care to check for nested tags at this point.</p>
  
  <p>I'm thinking that some recursion would be involved, inside the deReplace function.</p>
  
  <pre><code>function doReplace($keyword)
  {
   //if(!is_keyword_in_named_tag())
      return ' &lt;b&gt;'.trim($keyword).'&lt;/b&gt;';
  }
  
  function init()
  {
      $content = "This will be some xhtml formatted 
      content that will be resident on the page in memory";
      $theContent = 
        preg_replace_callback("/\b('my test string')\b/i","doReplace", $content);
      return $theContent;
  }
  </code></pre>
  
  <p>So if the $content variable contains...</p>
  
  <pre><code>&lt;h1&gt;This is my test string&lt;/h1&gt;
  </code></pre>
  
  <p>Then the string "my test string" would not be replaced.</p>
  
  <p>But if the #content variable contains...</p>
  
  <pre><code>&lt;h1&gt;This is my test string&lt;/h1&gt;
  &lt;div&gt;This is my test string too &lt;b&gt;my test string 3&lt;/b&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Then the replaced content would be...</p>
  
  <pre><code>&lt;h1&gt;This is my test string&lt;/h1&gt;
  &lt;div&gt;This is &lt;b&gt;my test string&lt;/b&gt; too &lt;b&gt;my test string 3&lt;/b&gt;&lt;/div&gt;
  </code></pre>