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 8135343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:23:34+00:00 2026-06-06T10:23:34+00:00

I have this common issue of ‘new line’ in php-csv which is making me

  • 0

I have this common issue of ‘new line’ in php-csv which is making me crazy!!! I checked so many forums and tried different workarounds, but it doesn’t seem to fix the problem. I’m reading from a CSV file which has 1 header and 2 data records. I skip the header using fgets() and reading the data records using $data=fgetcsv(). Now the problem is both the data records are read into single array. I tried the following options, but all in vain:

  1. Runtime – ini_set("auto_detect_line_endings", true);
  2. Turned auto_detect_line_endings to ‘ON’ in php.ini.
  3. tried fwrite($handle, implode($delimiter,$fieldsarray).PHP_EOL);

I’m working on MAMP in local, LAMP in dev region. The CSVs are saved on local machine, copied to /tmp/ folder and read from there. How can I check if there are necessary newlines in the files? When i check the file from tmp, I do see the records in new lines.

  • 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-06-06T10:23:36+00:00Added an answer on June 6, 2026 at 10:23 am

    The following solution worked!!

    $file_contents = file_get_contents($temp);
    $file_cont_new = str_replace("\n","\r",$file_contents);
    file_put_contents($temp,$file_cont_new);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems to be a common issue, and the solutions which I have seen
A common issue I have is getting confused what $(this) is referring to. I
This is a fairly common problem to which I have yet to find an
This is a very common scenario: displaying images in a ListView which have to
I have looked up this error, and it seems the common issue is caused
I have this association-list in Common Lisp: (defvar base-list (list (cons 'a 0) (cons
I have this query to calculate the most common days of the week and
I have code like this: public bool Set(IEnumerable<WhiteForest.Common.Entities.Projections.RequestProjection> requests) { var documentSession = _documentStore.OpenSession();
This must be a common problem with a common solution. I have a lot
This is a very common thing in web applications. If I have a user

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.