title: Prevent replacements of emoticons in HTML-tags
body: <p>I use a simple <code>str_replace</code>-function to replace some emoticons on my website…</p>
  
  <pre><code>&lt;?php
  
  $replace = array(
      ':)' =&gt; 'smile',
      ';)' =&gt; 'wink',
      …
  );
  
  $string = 'Lorem ipsum (&amp;quot;dolor&amp;quot;) sit amet! :)';
  
  foreach($replace as $search =&gt; $replace) {
      $string = str_replace($search, '&lt;img src="/img/'.$replace.'.png" alt="'.$search.'"&gt;', $string);
  }
  
  ?&gt;
  </code></pre>
  
  <p>The problem about this simple replacement is, that ";)" from the <code>&amp;quot;</code>-tag would be replaced aswell and the HTML-code would be broken. Is there any way/workaround (a special regex i.e.) to solve this "problem"? Thanks! :)</p>