as per http://www.php.net/manual/en/function.fopen.php this should work... but it still writes at the bottom of a file...:
$file=fopen("file.txt", "aw")
Is there any way to write at the TOP of the file without over writing existing data? (hence, append to the top, not the bottom of a file...)
You could read the file and concatenate the existing data to the end of the new data, then write back to the file.
how?
<? $filename = "text.txt";
$fp = fopen ($filename, "r"); $old_string = fread ($fp, filesize ($filename)); fclose($fp);
$string = "this is my new string".$old_string;
$fp = fopen ($filename, "w"); fwrite($fp, $string);
fclose($fp); ?>