The Little Guy Posted December 5, 2008 Share Posted December 5, 2008 I have this function, which converts BB Code to HTML (It works perfect for me) function bbc($text){ $find = array( '~\[img=(.*?)\]~s', '~\[url=(.*?)\](.*?)\[/url\]~s', '~\[ol\](.*?)\[/ol\]~s', '~\[ul\](.*?)\[/ul\]~s', '~\[li\](.*?)\[/li\]~s' ); $replace = array( '<img src="$1" />', '<a href="$1">$2</a>', '<ol>$1</ol>', '<ul>$1</ul>', '<li>$1</li>' ); return preg_replace($find,$replace,$text); } next, this is the part I am having an issue with this: echo '.bbc(nl2br($row['info'])); It converts the text how I want, the problem is with how it is displayed. after ever </li> tag, there is a <br> tag. I want to remove the <br> tag after ever </li> tag. How can I do it? Example data: We don't keep statistics of sites that are not registered. If you would like your site to get statistics about it, then please feel free to register or log into your accout, and you can add your site. [ol] [*][url=/login]Login [*]Create a new project [*]Follow the steps on the page [*]Copy our code to your website [/ol] Quote Link to comment Share on other sites More sharing options...
gevans Posted December 5, 2008 Share Posted December 5, 2008 You could do another match and replace; $searchfor = array ("</ol><br>","</ul><br>","</li><br>"); $replacewith = array ("</ol>","</ul>","</li>"); $yourstring = str_replace($searchfor,$replacewith,$yourstring); Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 5, 2008 Author Share Posted December 5, 2008 perfect, I just had to change <br> to xhtml <br /> Quote Link to comment Share on other sites More sharing options...
gevans Posted December 5, 2008 Share Posted December 5, 2008 my bad, just used the line break you had in your post Glad to see PHP is keeping up with XHTML standards!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.