Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.