Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9

Thread: BBCode Problem

  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default BBCode Problem

    Well, this is reverse BBCode

    For my reverse BBCode code, I have the following:
    PHP Code:
    function reversebb($string)
    {
    $bbcode = array('[b]\\1[/b]',
    '[strike]\\1[/strike]',
    '[u]\\1[/u]',
    '[color=\\1]\\2[/color]',
    ':heart:',
    ':diamond:',
    ':club:',
    ':spade:',
    ':tm:',
    '(l)',
    '[i]\\1[/i]',);

    $replace = array("'<b>(.*?)</b>'",
    "'<strike>(.*?)</strike>'",
    "'<u>(.*?)</u>'",
    "'<font color=\"(.*?)\">(.*?)</font>'",
    "'&hearts;'",
    "'&diams;'",
    "'&clubs;'",
    "'&spades;'",
    "'&trade;'",
    "'<img src=\"images/(l).gif\">'",
    "'<i>(.*?)</i>'",);

    $string preg_replace($replace$bbcode$string);

    $string str_replace("\n"""$string);

    $string str_replace("<br />\n""\n"$string);

    $string str_replace("<br />"""$string);

    return 
    $string;


    But, If $string is "<img src="images/(l).gif">", it dosn't display "(l)", it just displays "<img src="images/(l).gif">".

    Can anyone see whats wrong?

  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Yeah what the hell are you trying to do?

    (l)? As the BBcode? It's trying to match (l) and replace it into <img src="images/(l)">

    What exactly do you want it to do?

    For one you are not defining a variable in the search, nor the replace.

  3. #3
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    Yeah what the hell are you trying to do?

    (l)? As the BBcode? It's trying to match (l) and replace it into <img src="images/(l)">

    What exactly do you want it to do?

    For one you are not defining a variable in the search, nor the replace.
    Well, if your message is "Hey There (l)" it will insert it into the database like "Hey There <img src="images/(l).gif">".

    But for you to edit your comment, I want it to display as (l) again.

    All the other reversebb works such as [color] etc.. just not this one :S

    So its reversing BBCode.

  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    try this

    Code:
    '<img src=\"images/(l).gif\">'
    instead of "'<img src=\"images/(l).gif\">'"

  5. #5
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    try this

    Code:
    '<img src=\"images/(l).gif\">'
    instead of "'<img src=\"images/(l).gif\">'"
    Nope

  6. #6
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    This may be a stupid question to ask, but what is l.gif?

    Also, make sure that your editor isn't changing the brackets to the special character code
    Last edited by Calon; 17-09-2008 at 03:42 PM.

  7. #7
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    is it being stored on the server with slashes, etc?

  8. #8
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Calon View Post
    This may be a stupid question to ask, but what is l.gif?

    Also, make sure that your editor isn't changing the brackets to the special character code
    on msn type in (l)
    Quote Originally Posted by Dentafrice View Post
    is it being stored on the server with slashes, etc?
    That was the second thing I checked

    In the database, its storing it as <img src="images/(l).gif">

  9. #9
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    PHP Code:
    "'<img src=\"images/(l).gif\">'" 
    try this:

    PHP Code:
    '#<img src="images/(l).gif">#i'
    But no " ".

    Alternatively just parse bbcode on display, much easier.
    Last edited by Jewish Bear; 17-09-2008 at 04:20 PM.

Posting Permissions

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