Force new line when fwriting a CSV in PHP -


$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 adds bunch of csv lines stored in array file separated new line characters. file being written contains bunch of csv lines already.

the problem that, despite pre-pending the text written "\r\n", in newly written csv, new block starts on same line old one. implodes variable works fine.

stumped on this, been looking @ long cannot see problem simple.

dan

can start writing line:

fwrite($han, php_eol); fwrite($han, $out_text); 

as asside, while technically not matter, more this:

fwrite($han, php_eol); foreach( $out_array $out_text ) {     fwrite($han, $out_text); } 

i reserve writing large blocks of text (which include newlines) file_put_contents. technically not matter, , above more php 4 compliant (though doubt care anymore), have more standard "feel" it.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -