I create a CSV file for download by our client using
$output = fopen('php://output', 'w');
and using fputcsv()
to write data to a CSV file which is downloaded by the client.
I am running PHP on Linux and consequently the line endings are not interpreted by many Windows applications.
I could write the CSV file to a directory on the server, read it back in and perform a str_replace()
from \n
to \r\n
, but this seems a rather clunky way of solving the problem. Is there a way to perform the conversion without creating a physical file?