I am trying to write a string at a specific position in a file by using fseek() to place the file pointer, and fwrite() to write directly to the file (no buffer in a string or something like that).
however, it seems that fwrite() always writes at the end of the file no matter what!
the file is opened in "a+" mode, and when reading from the file the file pointer position makes a difference, but not when writing. is this a bug or am I making a mistake? thanks you for your time. here is a snippet of my code as well:
[...]
if (!$fp) {
$fp = fopen ($filename, "a+");
rewind($fp);
} // if
else {
rewind($fp);
} // else
[...]
$tag_pos = searchStringInFile($filename, $tag);
if ($tag_pos) {
fseek($subscribers_fp, $tag_pos);
fwrite($subscribers_fp, $subscriber_tag_string);
[...]
searchStringInFile() is my own function and it works well.