Hi guys,
i'm trying to store some strings to a text file. instead of opening a file and store the string to the last line of the txt file, how can i make the script to store the string from the first line? ... so that records will be in decending order.
appreciate your help, thanks 🙂
Use [man]fopen/man with the 'r+' mode, or do something like:
file_put_contents($filename, 'string here' . file_get_contents($filename));
thank you very much... it works!
No problem; don't forget to mark this thread resolved using the link under the Thread Tools menu.
Hi,
Apparently, i have problem with my new web hosting company, so i have to move back to my previous web hosting company, which is using php4
now, i'm having problem using file_put_contents.
any help would be appreciated, thanks.
well there is no file_put_contents on php4 so you have to write your own
stolen from the user notes in the manual:
function file_put_contents($filename, $data) { $f = @fopen($filename, 'w'); if (!$f) { return false; } else { $bytes = fwrite($f, $data); fclose($f); return $bytes; } }