Jump to content

BBCode help


EchoFool

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/251403-bbcode-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.