iceyd Posted March 20, 2011 Share Posted March 20, 2011 Hi, I was wondering if this is possible as I've been tasked (uni project) with creating a blog site that displays entries in order of creation. From what I've seen, when modifying the file I can only add entries from the bottom line and not from the top without replacing the previously stored content. Thank you. Link to comment https://forums.phpfreaks.com/topic/231219-adding-info-to-txt-file-from-the-top/ Share on other sites More sharing options...
tomfmason Posted March 20, 2011 Share Posted March 20, 2011 a simple way could be something like <?php $data = "some data \n"; $file = '/path/to/file'; $data .= file_get_contents($file); file_put_contents($file,$data); ?> Link to comment https://forums.phpfreaks.com/topic/231219-adding-info-to-txt-file-from-the-top/#findComment-1190067 Share on other sites More sharing options...
iceyd Posted March 20, 2011 Author Share Posted March 20, 2011 Thank you very much for the quick reply. It worked a charm Link to comment https://forums.phpfreaks.com/topic/231219-adding-info-to-txt-file-from-the-top/#findComment-1190083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.