I am trying to replace the CR - LF at the end of a text file with JUST a LF character (ascii 10). I am executing the following, but each line of the file is still created with an ascii 13 / ascii 10 (CR / LF). It puts both regardless of whether I try append just a CR or just a LF!
Can anybody explain what is going on?
<?php
if (!$fd1 = fopen("file.txt","r")) {
echo("Could not open uploaded file");
} else {
$fd2 = fopen("c:\mysql\bin\file2.txt", "w");
echo("Reformat started<BR>");
while (!feof($fd1)) {
$recordcount++;
$recbuffer = fgets($fd1, 4096);
$recbuffer = trim($recbuffer);
fputs($fd2,$recbuffer . chr(10));
}
echo("Reformat complete");
fclose($fd2);
fclose($fd1);
}
?>