I\'m writing a PHP script that adds numbers into a text file. I want to have one number on every line, like this:
1
5
8
12
If I use f
annoyingregistration, what you have there is absolutely fine. PHP_EOL and "\n" are exactly the same.
The code you provided theres nothing wrong with it so it must be the value of $commentnumber that has a space at the end of it. as stated, run your $commentnumber through the trim() function.
file_put_contents($filename, trim($commentnumber . "\n"), FILE_APPEND);
Good luck.