SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Formating

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formating

    When someone just copies and pastes something into a field, I dont think when the data is stored, that it keeps the formating, for example indents and line breaks. can that be fixed by just doing the addslashes() function, or is that only for things like: "

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    It does save the formatting, you just can't see the characters. Use the function nl2br()(new line 2 break) when displaying the text to change the \r\n, which is the invisible newline character, to html when displaying.

    If that doesn't work, then try addslashes(), stripslashes(), and then nl2br().

    There is no such thing as a tab in html, so you can't display the indenting in a similar way. I guess you could look for the \t (=tab) in the string, and then replace it with $nbsp; a couple of times before sending it to the browser.
    Last edited by 7stud; Jun 1, 2001 at 22:35.


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
  •