Skip to content
Advertisement

PHP newline not working in text file

I am using the PHP code:

$numberNewline = $number . 'n';
fwrite($file, $numberNewline);

to write $number to a file.

For some reason n appears in the file. I am on a mac. What might be the problem?

Advertisement

Answer

$numberNewline = $number . "n";
fwrite($file, $numberNewline);

Try this

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement