dtq7387 2015-10-07 15:47
浏览 13
已采纳

如何在任何单词之前将一些信息写入文件末尾?

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);
  • 写回答

1条回答 默认 最新

  • dongsimu4422 2015-10-07 15:55
    关注

    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

    Update #1

    Change the mode of your fopen to r+ as a will always write @ EOF

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?