Jump to content

[SOLVED] fseek/fwrite overwrites existing text


evanct

Recommended Posts

Okay so I want to open a file and insert some text in the middle of it. but when i fseek to the correct place and then fwrite, it overwrites the current text with the new text. for example if I have the text "abcdefg" in abc.txt and do this:

 

$f=fopen("abc.txt","r+");
fseek($f,1);
fwrite($f,"123");
fclose($f);

 

abc.txt would be changed to:

a123efg

 

how do I get around this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.