My code below writes the first line,
intermediate lines, and finally the
last line.
NOTE: I want to skip a line after writing the first,
and only the first, line.
But - putting the "\n" after the first write
causes ALL subsequent writes to ALSO skip
a line - something I do not want to happen,
even though those fwrites do NOT have the "\n"
in their syntax.
Why does the first write's skip action
influence the rest of the fwrites, and how,
then, do I get only the first skip executed
without causing further skips thereafter?
<?php
$file = fopen("./readArray.php","r");
$wfile = fopen("./writeArray.txt", "w");
fwrite($wfile, "var jsArray = [\n");
while(! feof($file))
{
$phpLine = fgets($file);
fwrite($wfile, $phpLine);
}
fclose($file);
fwrite($wfile, "]");
fclose($wfile);
?>
If I change the first fwrite statement to
fwrite($wfile, "var jsArray = [");
each write appears on their own line,
as I want it, except for the first line's
missing skip. How do I skip only
after the first fwrite?