Thread: Edit a file
View Single Post
Old 06-11-2009, 11:19 AM   #1 (permalink)
rupam_jaiswal
The Wanderer
 
rupam_jaiswal's Avatar
 
Join Date: Jun 2008
Posts: 8
Thanks: 0
rupam_jaiswal is on a distinguished road
Default Edit a file

Hi,
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.
Regards
rupam_jaiswal is offline  
Reply With Quote