I want write information to end of file before last word. How can I do that? My code:
$fp=fopen("sitemap.xml","a");
fwrite($fp, "
" . "My information");
fclose($fp);
I want write information to end of file before last word. How can I do that? My code:
$fp=fopen("sitemap.xml","a");
fwrite($fp, "
" . "My information");
fclose($fp);
Before the last word?
Seek to the end of the file, backtrack until first whitespace character, save all data from current point to EOF, insert your data, insert saved data
Change the mode of your fopen to r+
as a
will always write @ EOF