Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: BBCode help

  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    BBCode help

    heres my code:

    PHP Code:
    function icode($text)
    {
        
    $search = array('/\[b\](.*?)\[\/b\]/is''/\[i\](.*?)\[\/i\]/is''/\[u\](.*?)\[\/u\]/is''/\[url\=(.*?)\](.*?)\[\/url\]/is''/\[center\](.*?)\[\/center\]/is''/\[img\](.*?)\[\/img\]/is');
        
    $replace = array('<b>$1</b>''<i>$1</i>''<u>$1</u>''<a href="$1" target="_blank">$2</a>''<center>$1</center>''<img src="$1" border="0">');
        
    $string preg_replace($search$replace$text);
     return 
    $text;

    PHP Code:
    $article icode($article); 
    But that doesn't seem to be working =X Any help?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Hint:
    Code:
    function icode($text)
    {
        $search = array('/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[center\](.*?)\[\/center\]/is', '/\[img\](.*?)\[\/img\]/is');
        $replace = array('<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<a href="$1" target="_blank">$2</a>', '<center>$1</center>', '<img src="$1" border="0">');
        $string = preg_replace($search, $replace, $text);
        return $text;
    }

  • #3
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    lol thanks *slaps self*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •