SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Accredited Master scotty2260's Avatar
    Join Date
    Apr 2004
    Location
    California
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replace <RETURN>?

    I have a script where the user can add news, but the problem is, even though there are breaks int he content (from hitting enter/return) when I echo the content, the line break is not displayed.

    I'm guessing I need to replace line breaks with the actual line break code (<br>). but how do I replace something invisible like the return key?
    Scott

  2. #2
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a thread on this very topic from earlier today:
    http://www.sitepoint.com/forums/showthread.php?t=212386

    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  3. #3
    Accredited Master scotty2260's Avatar
    Join Date
    Apr 2004
    Location
    California
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ooops! I should have searched, I just assumed no one else would have such crazy problems as I do. hehe. thanks much.
    BTW here is the code I used if anyone else needs is.
    PHP Code:
    str_replace(Chr(13), "<br>"$test); 
    Scott

  4. #4
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There actually is a built in PHP function for that:
    PHP Code:
    $newLine nl2br $oldLine); 
    or
    PHP Code:
    echo nl2br $line ); 
    www.php.net/nl2br

    NL 2 BR => NewLine 2(to) <BR>

    Quaint Tech
    - Blog on web development and web technology.


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
  •