How to write in between content of existing file?
I tried to use fseek() to seek a new position and write the new content, but it replaces old content to the new string after seek position.
My aim is to put new contents after 5 characters of existing file.
Old content: AAAAABBBBB, desired content: AAAAAnewcontentBBBBB
$file_handler = fopen('putty.log','w');
$new_content = 'this is new content';
fseek($file_handler,5);
echo ftell($file_handler); //5
fwrite($file_handler,$new_content);
old content replaced with NULLNULLNULLNULLNULLthis is new content