Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 777169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:33:40+00:00 2026-05-14T19:33:40+00:00

I have a script that generates a csv file using the following code: header(‘Content-type:

  • 0

I have a script that generates a csv file using the following code:

header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="'.date("Ymdhis").'.csv"');
print $content;

The $content variable simply contains lines with fields separated by commas and then finalised with .”\n”; to generate a new line.

When I open the file in csv it looks fine however, when I try to use the file to import into an external program (MYOB) it does not recognise the End Of Line (\n) character and assumes one long line of text.

When I view the contents of the file in notepad, the end of line character (\n) is a small rectangle box which looks like the character code 0x7F.

If I open the file and re-save it in excel, it removes this character and replaces it with a proper end of line character and I can import the file.

What character do I need to be generating in PHP so that notepad recognises it as a valid End Of Line character? (\n) obviously doesn’t do the job.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:33:41+00:00Added an answer on May 14, 2026 at 7:33 pm

    Use “\r\n”. (with double quotes)

    The above is the ascii characters for carriage return + line feed.

    Historically this relates to the early days of computing on teletypes when the output was printed to paper and returning the carriage of the teletype head to the start of the line was a separate operation to feeding a line through the printer. You could overwrite lines by just doing a carriage return and insert blank lines by just a line feed. Doing both returned the head to the start of the line and fed it a new line to print on.

    What precisely was required differed between systems –

    • Line feed only: – most Unix like systems
    • Carriage return plus Line feed: – DEC amd MS-DOS based systems
    • Carriage return only: – Early Apple/Mac OS’s

    So what you’re generating at the moment is a newline on a Unix system only. Wikipedia has quite a good page on this.

    There’s actually unix command line tools to do the conversion too. The unix2dos and dos2unix commands convert ascii text files back and forward between the unix and dos formats by converting line feed to line feed plus carriage return and vica versa.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that generates images from text using PHP. It's working fine
I have a Ruby script that generates a UTF8 CSV file remotely in a
I have a tcsh script that generates a text file. One of the lines
I have a script that generates a new CSV file (in my web directory)
For automated testing (using Hudson) I have a script that generates a bunch of
I have script that reads remote file content and writes it to local server.
I have a script that generates a temporary HTML file that has links to
I have a script that will generate a CSV file. The purpose of the
I have a script that generates a log file with ANSI color codes in
I have a [SQL 2008] SSIS package that takes a CSV text file and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.