SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Oslo
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with lineshifts, "\n", in text file!

    I've a small piece of code which writes a few lines of text to file:

    $content .= "Order id: ".$this->order['orders_id']."\n";
    $content .= "Total price: ".$this->order['value']."\n";
    $content .= "Date Purchased: ".$this->order['date_purchased']."\n";

    Then $content is written to file using fwrite().

    This works fine, but when I open the file in notepad the text is not displayed line by line, but as a single continuous string. How can I make it appear line by line in notepad?

    This is necessary because a colleague of mine are using Visual Basic to read the file. And he tells me VB can only read files line by line, so his script won't work when there's only one line.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    \n or nl2br r html formated.....

  3. #3
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Oslo
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by reminder
    \n or nl2br r html formated.....
    I found \r\n to work out nicely

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that was the point

  5. #5
    SitePoint Member
    Join Date
    May 2002
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    \n - new line, ASCII 10 (Dec) / 0D (Hex)
    \r - carriage return, ASCII 13 (Dec) / 0A (Hex)

    \n - Unix line ending
    \r\n - Windows line ending
    \r - Mac line ending


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
  •