per esempio ho travato questo:
Codice PHP:
I needed to append, but I needed to write on the file s beginning, and after some hours of effort this worked for me:
$fh = fopen("file.txt", "r");
$fcontent = fread($fh, filesize("file.txt"));
$towrite = "$newcontent $fcontent";
$fh22 = fopen('file.txt', 'w+');
fwrite($fh2, $towrite);
fclose($fh);
fclose($fh2);