SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist Jedi007's Avatar
    Join Date
    Aug 2005
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dont n12br in [CODE]

    I'm making a bbcode with n12br, but when [CODE] makes <pre>, its double so its like:

    if ($var == $var2)]

    {

    ...etc

    How can I not do it in [CODE]

  2. #2
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no idea what you're asking.
    PHP News, Views and Community: http://www.phpdeveloper.org

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    New York City
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's because the "invisible" linefeeds in the text are being translated by <pre> as line breaks on the HTML page, and then when you add on the <br> that's being added by nl2br(), you get the double spaces between lines. Don't use the nl2br() function on the text, you don't need it if you're wrapping the text in <pre> tags.

  4. #4
    SitePoint Evangelist Jedi007's Avatar
    Join Date
    Aug 2005
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol, I already know why, but I want to know how to fix it, I want to make it so it doesnt n12br inbetween

  5. #5
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It has happened to me before...
    In cases like this, i use the oldschool str_replace("\n","<br>",$str) and that takes care of it or use the 5th example of nl2br here:
    http://us3.php.net/nl2br
    Someone has coded a br2nl function for you which is the opposite...


Bookmarks

Posting Permissions

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