SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast doubli's Avatar
    Join Date
    Sep 2001
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    TEXT AREA formatting

    Im of course working on a content management system (then again who isnt )

    One of the things I would like to find out the best way of formatting text posted via a form so it looks neat on the page.

    Mainly, where the user has put in line breaks this is reflected. Is there an easy way of taking stuff posted into a text area and interpretting where linebreaks should be?

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $text = nl2br($text);
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this also works. (theres another thread around here that i started on the same subject and this is what was suggested to me.)
    PHP Code:
    $message_body str_replace("\r\n""\n"$message_body); 
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With that line, the text won't actually be in separate lines if you output it as HTML, since \n is not HTML code, it'll be on new lines if you go to View Source, but not on the actual HTML page. Need to be <br /> tags to show up unless you're outputting the data to a textarea box.


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
  •