$out_text = "\r\n";
$out_text_body = implode("\r\n", $output_array);
$out_text = $out_text . $out_text_body;
fwrite($han, $out_text);
Code above successfully adds a bunch of CSV lines which are stored in an array to a file separated by new line characters. The file being written to contains a bunch of CSV lines already.
The problem is that, despite pre-pending the the text to be written with an extra “\r\n”, in the newly written CSV, the new block always starts on the same line as the old one. The implodes variable works fine.
Stumped on this, but been looking at it so long I cannot see the problem which is hopefully simple.
Dan
Can you just start by writing a line:
As an asside, while technically it does not matter, I would be much more likely to do this:
I generally reserve writing large blocks of text (which include newlines) to
file_put_contents. Technically it does not matter, and the above is more PHP 4 compliant (though I doubt we care about that anymore), but it does have a more standard “feel” to it.