the way I posted will also work.
although I did forget the part about opening the file and all hehe.
your fopen command should be placed after the $oldcontents=implode(blahblah...);
your fopen command should look like
fopen($filename, "w");
so to clear this all up... the entire thing should look something like:
$filename="example.txt";
$oldcontents=implode("", file($filename));
$newcontents="the new stuff to be at top";
$totcontents=$newcontents."\n".$oldcontents;
$fopen($filename, "w");
$fwrite($filename, $totcontents);
$fclose($filename);
make sense?
-Paddy
P.S. Stinger,
'r' - Open for reading only; place the file pointer at the beginning of the file.
'r+' - Open for reading and writing; place the file pointer at the beginning of the file.
'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' - Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' - Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
http://www.php.net/manual/en/function.fopen.php