Please excuse if similar query has been posted earlier.
I have text file in which I have to search a word and replace it with a new word.
First I do is to get the file contents with fopen,then read the contents , maintain a string $newcontent that holds the contents of file ,the moment i get my word,replace it with new word in the string $newcontent
After that I write the whole string $newcontent to file again.
What I want is to just while scanning the file,the moment I find my word,replace it with new word there only instead of rewriting the whole file again.
I don't know if there is a way with a file but don't quote me on this as I'm still quite knew myself however what you can do which i would recommend is create a .php file that will connect to a mysql database and then use the php file to create the .txt and then simply store your newcontent within a mysql database.
Basically to do that without having to enter then click a link to visit the php page you can take your form (im assuming your using a form to get your newcontent) and make it get processed in the .php page then make the php page update the mysql database, then read the database and output a .txt page and after it outputs the .txt page make it redirect to the .txt
Sorry if i did not answer your question, I will see if i can come up with anything.
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
I know for sure that the easiest ways are to either rewrite the file or concatenate the information into the file. I would assume that what you are looking for is possible, I would just need to research the answer a little but more though.
My guess would be by opening the file, reading its contents, noting where the change(s) need to be, positioning the pointer, and then editing the data. Possible, most likely... pain in the ass, absolutely.
__________________ Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.