我堅持在這里。我有在修改第一個文本檔案時重命名我的文本檔案的功能。
function copyFiles(string $newLine) : void
{
rename( "file4.txt", "file5.txt");
rename( "file3.txt", "file4.txt");
rename("file2.txt", "file3.txt");
rename("file1.txt", "file2.txt");
file_put_contents("file1.txt",$newLine."\n", FILE_APPEND|LOCK_EX);
}
我需要從最后一個內容中獲取內容file5.txt
并將其放入另一個名為的文本檔案中fullnews.txt
如果fullnews.txtisHello World和 in 中的內容file5.txt是Good afternoon World
當我修改第一個檔案后,我需要fullnews.txt看起來像
Good afternoon World
Hello World
uj5u.com熱心網友回復:
我認為對于這樣的小字串,最好的方法是讀取并存盤 file5.txt 的內容,然后將讀取的內容附加到 fullnews.txt。
$content = file_get_contents("file5.txt");
file_put_contents("fullnews.txt", $content, FILE_APPEND);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/417921.html
標籤:
