gpt4 book ai didi

php - 如何大量写入txt文件开头的字符串?

转载 作者:行者123 更新时间:2023-12-04 06:27:38 34 4
gpt4 key购买 nike

我的网络服务器上有 100 个 txt 文件。我必须插入一个字符串,例如abcdef 在所有这些使用 php 的开头并再次保存它们。这怎么可能 ?

最佳答案

opendir , glob , fopen , 和 fwrite .例如:

foreach (glob("*.txt") as $file) {
$fh = fopen($file, 'c'); //Open file for writing, place pointer at start of file.
fwrite($fh, 'abcdef');
fclose($fh);
}

关于php - 如何大量写入txt文件开头的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5851962/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com