Want to use BBCode

Discussion in 'Programming' started by heavener, Jun 20, 2008.

  1. #1
    Hello everyone, thanks for reading my post...

    I am thinking about building a social network website in PHP and MySQL and need help.
    I need to lay down a few restrictions on the site, with the profile.
    I was wondering how I could incorporate BBCode in my profile page. You know, where you edit a profile, you enter BBcode in and the result on the view profile page would be HTML.

    Also, for the future, when I'm developing the social site, I'm just wondering how everyone would picture the perfect social site? Would would you like on YOUR profile/gallery/social site? If you have some good ideas I'll try and incorporate and leave a thanks on the site to you. But they have to be awesome ideas. Lol.

    Anyone suggestions would be greatly appreciated.
    I really do need help with the BBcode though.
    Thanks.
     
    heavener, Jun 20, 2008 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Simplest method

    function ParseBBCode($text) {
        $bbcodes = explode(",","[b],[/b],[i],[/i],[u],[/u]");
        $replaces = explode(",","<b>,</b>,<i>,</i>,<u>,</u>");
        return str_replace($bbcodes,$replaces,$text);
    }
    Code (markup):
    Usage

    $text = "My name is [b]Vooler[/b] at [u]digitalpoint[/u]";
    
    $text = ParseBBCode($text);
    Code (markup):
    Text is now:
    My name is <b>Vooler</b> at <u>digitalpoint</u>


    If you need regex match function for more bbcodes and conditional replacements, le tme know.

    I hope it helps.

    regards
     
    Vooler, Jun 21, 2008 IP