title: Allow <a> and <b> tags in PHP function?
body: <p>I currently have use this function to clean inputs submitted by users:</p>
  
  <pre><code>// Cleaning input functions
  function clean_Input($input) {
      $search = array(
          '@&lt;script[^&gt;]*?&gt;.*?&lt;/script&gt;@si', // Strip out javascript
          '@&lt;[\/\!]*?[^&lt;&gt;]*?&gt;@si', // Strip out HTML tags
          '@&lt;style[^&gt;]*?&gt;.*?&lt;/style&gt;@siU', // Strip style tags properly
          '@&lt;![\s\S]*?--[ \t\n\r]*&gt;@' // Strip multi-line comments
      );
      $output = preg_replace($search, '', $input);
      return $output;
  }
  
  function sanitize($input) {
      if (is_array($input)) {
          foreach ($input as $var =&gt; $val) {
              $output[$var] = sanitize($val);
          }
      } else {
          if (get_magic_quotes_gpc()) {
              $input = stripslashes($input);
          }
          $input  = clean_Input($input);
          $output = mysql_real_escape_string($input);
      }
      return $output;
  }
  </code></pre>
  
  <p>However, I want to edit it so that it WILL allow <code>&lt;a&gt;</code> and <code>&lt;b&gt;</code> tags to pass through. Meaning it will accept links and bold tags, and WON'T remove them.</p>
  
  <p>Currently, it removes all HTML tags including <code>&lt;a&gt;</code> tags and <code>&lt;b&gt;</code> tags, how can I change it to accomplish what I stated above?</p>
  
  <p>If I knew how to work with the <code>preg_replace</code> function I would've tried something. However, I'm completely stuck, and have absoultely no idea where to go from here.</p>