title: PHP BBCode Parser
body: <p>I have a tiny bbcode parser which works very well, except pre and code tags. I need to make pre and code tags ignored by the whole parser function. How would I achive this ? If any one have an idea please let me know.</p>
  
  <p>What I'm trying to do is when I use <code>&lt;pre&gt;</code> or <code>&lt;code&gt;</code> tags it will ignore the bbcode used inside, but parse it everywhere else on the page. I think it can be achived with regex and preg_match or preg_replace some how.</p>
  
  <pre><code>function parse($text) {
  
    $search = array(
      '/\*\*(.*?)\*\*/is',  // bold
      '/\/\/(.*?)\/\//is',  // italic
      '/__(.*?)__/is',    // underline
    ); #search
  
    $replace = array(
      '&lt;b&gt;$1&lt;/b&gt;',
      '&lt;i&gt;$1&lt;/i&gt;',
      '&lt;u&gt;$1&lt;/u&gt;',
    ); #replace
  
    return preg_replace($search, $replace, $text);
  
  } #parse
  
  
  
  &lt;pre&gt;
  
    ** Bold Text **
    // Italic Text //
    __ Uderline Text __
  
  &lt;/pre&gt;
  
  &lt;code&gt;
  
    ** Bold Text **
    // Italic Text //
    __ Uderline Text __
  
  &lt;/code&gt;
  </code></pre>
  
  <p>Any help will be apreceated. Thank you.</p>