PHP New Line will not work
Posted
by user364333
on Stack Overflow
See other posts from Stack Overflow
or by user364333
Published on 2010-06-13T08:37:05Z
Indexed on
2010/06/13
8:42 UTC
Read the original article
Hit count: 180
Hi I am trying to create some code that first reads the existing contents of the file in and then adds the new line of code on a new line but the code i am using just adds it on the new text on to the already existing line instead of the new line...
Here is the code i am using:
<?php
$id = $_GET['id'];
$userfile = "user1.txt";
$fo = fopen($userfile, 'r') or die("can't open favourites file");
$currentdata = fread($fo, filesize($userfile));
fclose($fo);
$fw = fopen($userfile, 'w') or die("can't open favourites file");
$currentprocessed = "$currentdata\n";
fwrite($fw, $currentprocessed);
fwrite($fw, $id);
fclose($fw);
?>
I have tried a whole range of different ideas but nothing has worked, any help would be appreciated.
© Stack Overflow or respective owner