title: Use htmlspecialchars but allow <a href="URL">...</a>
body: <p>Use htmlspecialchars but allow <code>&lt;a href="URL"&gt;...&lt;/a&gt;</code>.<br/>
  Extra spaces should also be valid, like <code>&lt; a href =</code>.</p>
  
  <hr>
  
  <pre><code>$pureHTML = htmlspecialchars($dirtyHTML,ENT_QUOTES);
  </code></pre>
  
  <p>Now maybe I need a <code>preg_replace</code> on <code>$pureHTML</code>, but what should be the <code>preg_replace</code>? Or do you recommend using <a href="http://htmlpurifier.org/" rel="nofollow">HTML Purifier</a>?</p>
  
  <p>I want to allow anchor tag pair only for href attribute. Onclick, target attributes are not allowed.</p>