Connecting Tech Pros Worldwide Forums | Help | Site Map

how to clear a .txt file with php

Jan
Guest
 
Posts: n/a
#1: Jul 17 '05
I'm busy making a very basic and simple content management system wich
stores the text in a .txt file. now i need to know how i can clear the
..txt file.. now it just adds the new text to the .txt file while it
should replace it!
I also like to display the old text in the textarea... help me please!

Tim Van Wassenhove
Guest
 
Posts: n/a
#2: Jul 17 '05

re: how to clear a .txt file with php


On 2003-12-20, Jan <janvanderburgt@hotmail.com> wrote:[color=blue]
> I'm busy making a very basic and simple content management system wich
> stores the text in a .txt file. now i need to know how i can clear the
> .txt file.. now it just adds the new text to the .txt file while it
> should replace it!
> I also like to display the old text in the textarea... help me please![/color]


http://www.php.net/manual/nl/ref.filesystem.php

Here you find everything you need to know...

--
verum ipsum factum
DaWaN
Guest
 
Posts: n/a
#3: Jul 17 '05

re: how to clear a .txt file with php


to display the old text then open the file for read first
fopen('filename.txt', 'r') and display the content, then when you wanna
replace the content with the new text just
open the file for write and it'll truncate the content.
fopen('filename.txt', 'w') will do

--

===========================
DaWaN
dawan57@hotmail.com




"Jan" <janvanderburgt@hotmail.com> wrote in message
news:541da53e.0312200506.5f78db54@posting.google.c om...[color=blue]
> I'm busy making a very basic and simple content management system wich
> stores the text in a .txt file. now i need to know how i can clear the
> .txt file.. now it just adds the new text to the .txt file while it
> should replace it!
> I also like to display the old text in the textarea... help me please![/color]


Closed Thread