| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
|
|
#5 (permalink) |
|
Senior Member
|
Take a look at PHP's string replacing functions - str_replace at php.net - you could also try using regular expressions to do the same thing depending on what you wanted to replace in your document. |
|
|
|
#6 (permalink) |
|
volkswagen yellow & gold
Join Date: Apr 2003
Location: london, england.
Posts: 6,214
|
if you just want to replace part of an html page, then you could have a text file as an include which you then edit through php. that way, a section of text on a page can be edited and the html code is not touched. |
|
|
|
#7 (permalink) | |
|
Registered User
Join Date: Mar 2004
Location: Derby, UK
Posts: 24
|
Quote:
The standard approach is to read in the content of the file, alter it then write it back out. Generally you cannot edit the middle of the file without following this process unless the changes do not alter the number of bytes. To explain what I mean, imagine you have this in your file on disk abcdefghijklmnop and you want to change efg to ggffee. If you only read the middle part of the file (putting aside how you know where to read from) then tried to write the new version back at the same location in the file you would get abcdggffeeklmnop because what you wrote back was longer than the original and so would overwrite 'hij' as well, thus messing up the rest of the file. If you happened to be writing back the same number of bytes e.g. 'gfe' then you could in theory write it directly over the original using fseek() to move to the correct part of the file before writing, but usually it is read whole file change it write it back over the top of the original. HTH, Dai |
|
|
![]() |