Rosst Posted September 13, 2006 Share Posted September 13, 2006 Hello, I have a small problem with my bbcode, I got it fixed here at php freaks, and I thought it was OK the way it was, what happens is when I use bbcode there are massive spaces between lines, and I need that to be fixed, example of what it looks like: http://vexxon.net/index.php?id=tuts&cat=PHP&tutid=1example of what I want it to look like: http://dannyscripts.com/?view=tutorials&act=tutorial&id=101And my code:[code]<?function bbcode($content){ $bbcode = array( "'\[b\](.*?)\[/b\]'", "'\[i\](.*?)\[/i\]'", "'\[u\](.*?)\[/u\]'", "'\[code\](.+?)\[/code\]'", "'\[url=(.*?)\](.*?)\[/url\]'", "'\[url\](.*?)\[/url\]'", "'\[img\](.*?)\[/img\]'", "'\[red\](.*?)\[/red\]'", "':\)'", "':p'", "':o'", "':huh\?:'", "':C'", "':D'", "':lol:'", "':shades:'", "':blink:'", "':blush:'", "'!!'", "':check:'", ); $html = array( "<b>\\1</b>", "<i>\\1</i>", "<u>\\1</u>", "<strong>Code:</strong><div style=\"margin:0px 10px;padding:5px;border:1px dotted #000000;width:80%;\"></em>\\1</em></div>", "<a href=\"\\1\" target=\"_BLANK\">\\2</a>", "<a href=\"\\1\" target=\"_BLANK\">\\1</a>", "<img border=\"0\" src=\"\\1\">", "<font color=\"#FF6600\">\\1</font>", "<img src=\"includes/smileys/smile.gif\">", "<img src=\"includes/smileys/tongue.gif\">", "<img src=\"includes/smileys/ohmy.gif\">", "<img src=\"includes/smileys/huh.gif\">", "<img src=\"includes/smileys/angry.gif\">", "<img src=\"includes/smileys/biggrin.gif\">", "<img src=\"includes/smileys/laugh.gif\">", "<img src=\"includes/smileys/cool.gif\">", "<img src=\"includes/smileys/blink.gif\">", "<img src=\"includes/smileys/blush.gif\">", "<img src=\"includes/smileys/!!.gif\">", "<img src=\"includes/smileys/check.gif\">", ); $content = preg_replace($bbcode, $html, $content); // call a dedicated function to highlight our php code. $content = preg_replace_callback("#\[php\](.*?)\[\/php\]#is", 'highlight_php', $content); return stripslashes(nl2br($content));}function highlight_php($matches){ $php = "<strong>PHP:</strong><div style=\"margin:0px 10px;padding:5px;border:1px dotted #000000;width:80%;\"></em>"; $php .= highlight_string($matches[0], true); $php .= '</em></div>'; //strip out line breaks: $php = str_replace("<br />", '', $php); // strip out PHP BBCode tags: $php = preg_replace("#(\[php\]|\[/php\])#i", "", $php); return $php;}?>[/code]Thanks to anyone who can help! Quote Link to comment https://forums.phpfreaks.com/topic/20574-small-problem-with-bbcode/ Share on other sites More sharing options...
Rosst Posted September 13, 2006 Author Share Posted September 13, 2006 Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/20574-small-problem-with-bbcode/#findComment-91380 Share on other sites More sharing options...
wildteen88 Posted September 14, 2006 Share Posted September 14, 2006 I do not see the problem. The highlighted PHP code looks fine to me, and is more readable compared to the site you have linked to.Could you define what you mean by massive spaces between lines. Quote Link to comment https://forums.phpfreaks.com/topic/20574-small-problem-with-bbcode/#findComment-91638 Share on other sites More sharing options...
Rosst Posted September 17, 2006 Author Share Posted September 17, 2006 I fixed it.. Thanks any way Quote Link to comment https://forums.phpfreaks.com/topic/20574-small-problem-with-bbcode/#findComment-93598 Share on other sites More sharing options...
Rosst Posted September 30, 2006 Author Share Posted September 30, 2006 Hmm, I need help again, see right now I am looking at one of the tutorials I posted on my site and I see [code=php:0] in it, but it shouldn't be there, and there is a gap at the top, does anyone know how to fix it? Sometimes it doesn't even highlight it... http://vexxon.net/index.php?id=tuts&cat=12&tutid=1 there it is, you can see, I am using the same code I posted before Quote Link to comment https://forums.phpfreaks.com/topic/20574-small-problem-with-bbcode/#findComment-101244 Share on other sites More sharing options...
wildteen88 Posted September 30, 2006 Share Posted September 30, 2006 Could you post the code here for the highlight_php function. Also the C/C++ code will not be highlighted as its is not php code, and the highlight_string functionwill only highlight the php code if you add the php tags in (<?(php) ?>) if the open/closing php tags are not there the highlight_string function will not highlight the php code. Quote Link to comment https://forums.phpfreaks.com/topic/20574-small-problem-with-bbcode/#findComment-101343 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.