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] Link to comment https://forums.phpfreaks.com/topic/135585-solved-remove-line-break-after-every-list-item/ 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); Link to comment https://forums.phpfreaks.com/topic/135585-solved-remove-line-break-after-every-list-item/#findComment-706388 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 /> Link to comment https://forums.phpfreaks.com/topic/135585-solved-remove-line-break-after-every-list-item/#findComment-706404 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!! Link to comment https://forums.phpfreaks.com/topic/135585-solved-remove-line-break-after-every-list-item/#findComment-706408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.