title: Mark text in HTML
body: <p>I have some plain text and html. I need to create a PHP method that will return the same html, but with <code>&lt;span class="marked"&gt;</code> before any instances of the  text and <code>&lt;/span&gt;</code> after it.</p>
  
  <p>Note, that it should support tags in the html (for example if the text is <code>blabla</code> so it should mark when it's <code>bla&lt;b&gt;bla&lt;/b&gt;</code> or <code>&lt;a href="http://abc.com"&gt;bla&lt;/a&gt;bla</code>.</p>
  
  <p>It should be incase sensitive and support long text (with multilines etc) either.</p>
  
  <p>For example, if I call this function with the text "my name is josh" and the following html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;My Name Is Josh!!!&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;my name is &lt;b&gt;josh&lt;/b&gt;&lt;/h1&gt;
      &lt;div&gt;
          &lt;a href="http://www.names.com"&gt;my name&lt;/a&gt; is josh
      &lt;/div&gt;
  
      &lt;u&gt;my&lt;/u&gt; &lt;i&gt;name&lt;/i&gt; &lt;b&gt;is&lt;/b&gt; &lt;span style="font-family: Tahoma;"&gt;Josh&lt;/span&gt;.
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>... it should return:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;span class="marked"&gt;My Name Is Josh&lt;/span&gt;!!!&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;&lt;span class="marked"&gt;my name is &lt;b&gt;josh&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;
      &lt;div&gt;
          &lt;span class="marked"&gt;&lt;a href="http://www.names.com"&gt;my name&lt;/a&gt; is josh&lt;/span&gt;
      &lt;/div&gt;
  
      &lt;span class="marked"&gt;&lt;u&gt;my&lt;/u&gt; &lt;i&gt;name&lt;/i&gt; &lt;b&gt;is&lt;/b&gt; &lt;span style="font-family: Tahoma;"&gt;Josh&lt;/span&gt;&lt;/span&gt;.
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks.</p>