EchoFool Posted November 18, 2011 Share Posted November 18, 2011 Hey, I am trying to make a BBCode which quotes a post. But if a user quotes a post where the post they are quoting... contains a quote already from a previous post (still with me?) then the CSS messes up and im not sure why. In short if you quote a post which is already quoting a post then the problem arises. My function is: <?php function bbcode ($string) { // All the default bbcode arrays. $bbcode = array( //Text Apperence '#\[b\](.*?)\[/b\]#si' => '<b>\\1</b>', //Other '#\[url=http://(.*?)\](.*?)\[/url]#si' => '<a href="\\1" target="_blank">\\2</a>', '#\[quote\](.*?)\[/quote\]#si' => '<div class="quote_body">\\1<>', '#\[img\](.*?)\[/img\]#si' => '<img src="\\1">', ); $output = preg_replace(array_keys($bbcode), array_values($bbcode), $string); return $output; } echo nl2br(bbcode($message)); ?> The HTML came out like this: <div class="quote_body"> Posted By <b>Username</b> <br/> [quote] Posted By <b>Username</b> <br/> Content of post <br /><br/> Content of post [/quote] <br/><br/> Content of Post As you can see above some times it didn't change "quote" it left it and didn't convert it to my CSS. Any idea why? 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.