append to beginning of file
Posted: Fri Mar 17, 2006 2:11 pm
Hi everyone,
I have a php script that takes input from an html form and puts it in a text file. Basically its kind of like a web-log so i want the newest entry to be at the TOp of the text file, not at the bottom. Heres my source:
As you can see its just a simple script. Ive tried to use the rewind command but it still appeneds to the end of the file. I must not be using it correctly.
Thanks for any help! andy
I have a php script that takes input from an html form and puts it in a text file. Basically its kind of like a web-log so i want the newest entry to be at the TOp of the text file, not at the bottom. Heres my source:
Code: Select all
<?php
$formating = "<p>testformat<p>";
// Open the file
$fp = fopen("test.html", "a+");
// Write the data to the file
rewind($fp);
fwrite($fp, $formatting);
fwrite($fp, $newsupdate);
// Close the file
fclose($fp);
?>Thanks for any help! andy
Code: Select all