phpfputcsv

Use fputcsv but create many tables


If you have a single block of data, creating a table with fputcsv works great; it assumes the first row is a header and the following rows are of the same format.

But what do you do if you have multiple, differently formatted blocks of data you want to write out to a CSV:

Business Name: name-of-business.   Date: current date

Notes: single line of notes


Model | Product 
model1 | Product 1
model2 | Product 2
model3 | Product 3

The first line is basically a single line table with 4 columns and no headers The second line is a single line table with 2 columns and no headers Then the data - typical two column table with headers


Solution

  • As requested:

    But what do you do if you have multiple, differently formatted blocks of data you want to write out to a CSV:

    You'd then have your own propitary definition of a CSV... it's not what I would expect from a CSV though, so don't blame on others if they can't understand your CSV :)

    CSV has a RFC, there's nothing more to expect from CSV than what's commented there I guess.