You need to open the file for editing, find the desired position and then write to the file, for example:
<?php
$file = fopen($filename, "c");
fseek($file, -3, SEEK_END);
fwrite($file, "whatever you want to write");
fclose($file);
?>
Further link to php.net - fseek doc
Hope this helps.
source
share