I'm writing a little php script to add text to a txt file, but need to add it to the beginning of the file without erasing it all. Any ideas? AFAIK fwrite doesn't do this...
I'm writing a little php script to add text to a txt file, but need to add it to the beginning of the file without erasing it all. Any ideas? AFAIK fwrite doesn't do this...
Stick the file in $variable, $variable = $sometextyouwantoadd . $variable, write the file?
"Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."
Thanks - should have thought of that myself![]()
the function fopen (http://us2.php.net/manual/en/function.fopen.php) takes a parameter for where to start reading and writing.
However opening at the beginning overwrites the file - only opening 'a' allows you to add and that's at the end.Originally Posted by awm
I guess there's no clever way to do it, I'd take Mike suggestion then, it should work great.
There are currently 1 users browsing this thread. (0 members and 1 guests)