1

i am getting the CSV output as in this photo, which inserts extra blank lines in between the data. Can it be fixed? I tried trim(). But it didn't work.

Urgent ?

2
  • paste your csv content please Commented May 9, 2012 at 6:30
  • This is the CSV content in photo i.imgur.com/x2mWb.png Rest content is "Header 1","Header 2","Header 3" "row 1, cell 1","row 1, cell 2","row 1, cell 3" "row 2, cell 1","row 2, cell 2","row 2, cell 3" Commented May 9, 2012 at 6:31

1 Answer 1

3

Try adding

if (!empty($td))

before each fputcsv() call.

THs only exist in the first iteration and TDs don't exist in the first iteration so you're probably adding empty data on every iteration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.