title: PHP Preg_Replace REGEX BB-Code
body: <p>So I have created this function in PHP to output text in the required form. It is a simple BB-Code system. I have cut out the other BB-Codes from it to keep it shorter (Around 15 cut out)</p>
  
  <p>My issue is the final one [title=blue]Test[/title] (Test data) does not work. It outputs exactly the same. I have tried 4-5 different versions of the REGEX code and nothing has changed it.</p>
  
  <p>Does anyone know where I am going wrong or how to fix it?</p>
  
  <pre><code>function bbcode_format($str){
  $str = htmlentities($str);
  $format_search =  array(
  '#\[b\](.*?)\[/b\]#is',
  '#\[title=(.*?)\](.*?)\[/title\]#i'
  );
  $format_replace = array(
  '&lt;strong&gt;$1&lt;/strong&gt;',
  '&lt;div class="box_header" id="$1"&gt;&lt;center&gt;$2&lt;/center&gt;&lt;/div&gt;'
  );
  $str = preg_replace($format_search, $format_replace, $str);
  $str = nl2br($str);
  return $str;
  }
  </code></pre>