Hey. I am trying to create code that first reads the existing contents of a file and then adds a new line of code to a new line, but the code I use just adds it to new text on an existing line instead of a new line ...
Here is the code I'm 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 tried a number of different ideas, but nothing worked, any help would be appreciated.
source
share