PHP
(quick examples)
OVERRIDE FILE file_put_contents("demo.txt", "STRING");
APPEND TO FILE file_put_contents("demo.txt", "STRING", FILE_APPEND);
OPEN FILE STREAM $fh = fopen("demo.txt", "w"); OVERRIDE $fh = fopen("demo.txt", "a"); APPEND
WRITE TO FILE fwrite($fh, "STRING"); fclose($fh);
ARRAY OF DATA $arr = ["A", "B", "C"];
USE \R\N TO WRITE NEW LINE $fh = fopen("FILE", "w"); foreach ($arr as $a) { fwrite($fh, "$a\r\n"); }
CLOSE FILE fclose($fh);
ARRAY OF DATA $arr = [ ["A", "B", "C"], ["D", "E", "F"] ];
WRITE CSV $fh = fopen("demo.csv", "w"); foreach ($arr as $a) { fputcsv($fh, $a); }
CLOSE FILE fclose($fh);