say we have this file test.txt:
{}
And we want to add text between { and }.
I tried this:
$f = new SplFileObject($filepath, 'r+');
$f->fseek(1);
$f->fwrite('test');
but the output is {test, I tried also other modes like w+ (result-> test), a+ (result-> {}test
EDIT: forgot to tell that I dont want to load all the contents of the file to the memory, thats why I using SplFileObject