title: Error On Bulletin Board Conversion
body: <p>I copied this text from docs of PHP ( <a href="http://php.net/manual/en/function.bbcode-create.php" rel="nofollow" title="PHP: bbcode_create">PHP: bbcode_create</a> ) and modified it to quick use for BB Codes. But whenever there is line break between two BB Codes eg. between <code>[b]</code> and <code>[/b]</code> it doesn't converts the code.</p>
  
  <p>Here is the code I used:</p>
  
  <pre><code>function bb_codes($string) { 
          $tags = 'b|i|size|color|center|quote|url|img|li|list|s'; 
          while (preg_match_all('`\[('.$tags.')=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key =&gt; $match) { 
              list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]); 
              switch ($tag) { 
                  case 'b': $replacement = "&lt;strong&gt;$innertext&lt;/strong&gt;"; break; 
                  case 's': $replacement = "&lt;strike&gt;$innertext&lt;/strike&gt;"; break; 
                  case 'i': $replacement = "&lt;em&gt;$innertext&lt;/em&gt;"; break; 
                  case 'size': $replacement = "&lt;span style=\"font-size: $param;\"&gt;$innertext&lt;/span&gt;"; break; 
                   case 'list': if(!empty($param)){ $replacement = "&lt;ol&gt;$innertext&lt;/ol&gt;"; } else{ $replacement = "&lt;ul&gt;$innertext&lt;/ul&gt;"; } break; 
                   case 'li': $replacement = "&lt;li&gt;$innertext&lt;/li&gt;"; break;    
                  case 'color': $replacement = "&lt;span style=\"color: $param;\"&gt;$innertext&lt;/span&gt;"; break; 
                  case 'center': $replacement = "&lt;div class=\"centered\"&gt;$innertext&lt;/div&gt;"; break; 
                  case 'quote': $replacement = "&lt;blockquote&gt;$innertext&lt;/blockquote&gt;" . $param? "&lt;cite&gt;$param&lt;/cite&gt;" : ''; break; 
                  case 'url': $replacement = '&lt;a href="' . ($param? $param : $innertext) . "\"&gt;$innertext&lt;/a&gt;"; break; 
                  case 'img': 
                      list($width, $height) = preg_split('`[Xx]`', $param); 
                      $replacement = "&lt;img src=\"$innertext\" " . (is_numeric($width)? "width=\"$width\" " : '') . (is_numeric($height)? "height=\"$height\" " : '') . '/&gt;'; 
                  break; 
                  case 'video': 
                      $videourl = parse_url($innertext); 
                      parse_str($videourl['query'], $videoquery); 
                      if (strpos($videourl['host'], 'youtube.com') !== FALSE) $replacement = '&lt;embed src="http://www.youtube.com/v/' . $videoquery['v'] . '" type="application/x-shockwave-flash" width="425" height="344"&gt;&lt;/embed&gt;'; 
                      if (strpos($videourl['host'], 'google.com') !== FALSE) $replacement = '&lt;embed src="http://video.google.com/googleplayer.swf?docid=' . $videoquery['docid'] . '" width="400" height="326" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;'; 
                  break; 
              } 
              $string = str_replace($match, $replacement, $string); 
          } 
          return $string; 
      } 
  </code></pre>
  
  <p>Thanks in Advance!</p>
  
  <p>P.S: I edited the <code>s</code>, <code>list</code> and <code>li</code> only!</p>