且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用 PHP 覆盖文件中的行

更新时间:2023-12-04 14:45:31

如果文件不是太大,***的方法可能是将文件读入带有 file(),在行数组中搜索您的字符串并编辑该行,然后 implode() 将数组重新组合在一起并将 fwrite() 返回到文件.

If the file isn't too big, the best way would probably be to read the file into an array of lines with file(), search through the array of lines for your string and edit that line, then implode() the array back together and fwrite() it back to the file.