473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to clear a .txt file with php

Jan
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!
Jul 17 '05 #1
2 23064
On 2003-12-20, Jan <ja************@hotmail.com> wrote:
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!

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

Here you find everything you need to know...

--
verum ipsum factum
Jul 17 '05 #2
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
da*****@hotmail.com


"Jan" <ja************@hotmail.com> wrote in message
news:54**************************@posting.google.c om...
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!

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kenneth | last post by:
I have a flat file on the server which I append to from a HTML web form. I need to delete the last line of the flat file before I append though. How do i do that? I have the following code. ...
3
by: Tony Murphy | last post by:
Strange problem, I read a file into a string using ifstream, ostringstream and string and end part of the file is missing (file size ~9.5kb, ~9k read). its a html file. using windows nt 4 ...
2
by: Nobody You Know | last post by:
My goal is to efficiently read a file into a c++ string, discarding newlines. Here is my first cut: bool MyClass::ReadFile( string strFileName ) { ifstream File( strFileName.c_str() ); if (...
15
by: SK | last post by:
Hey folks, I am searching for a string (say "ABC") backwards in a file. First I seek to the end. Then I try to make a check like - do { file.clear (); file.get(c); file.seekg(-2,...
3
by: DHarry | last post by:
How can I clear a text file without deleting and creating a new (empty) file?
2
by: horneye | last post by:
After i use fstream to open a file, how can i use the fstream object to clear file's content?
9
by: Use*n*x | last post by:
Hello, I have a binary file (image file) and am reading 4-bytes at a time. The File size is 63,480,320 bytes. My assumption is that if I loop through this file reading 4 bytes at a time, I...
5
by: lovecreatesbea... | last post by:
The condition at line 31 is added to check if the program finished to read the whole file. Is it needed and correct? Thank you. #include <fstream> #include <iostream> #include <string> using...
1
intOwnsVoid
by: intOwnsVoid | last post by:
This program compiles but it's not searching properly. Circle.h #ifndef CIRCLE_H #define CIRCLE_H #include <iostream> #include <fstream> using namespace std;
0
by: tochins | last post by:
Hello, I have a code with which I can parse a file of around 1MB. However I am looking to parse an xml file of about 128MB. Below is my code Dim xml_doc As New DOMDocument Dim brtn As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.