配置项
$fileNameRead = 'a.log';//路径 + 文件名
$fileNameWrite = 'b.log';
//每次读取的字符40K 根据实际情况以及服务器的IO来调整这个参数
$chunk = 40960;
$charCount = filesize($fileNameRead);
$fpRead = fopen($fileNameRead, 'r');
$fpWrite = fopen($fileNameWrite, 'a');
for ($i = 0; $i < $charCount; $i += $chunk) {
fseek($fpRead, $i);
fwrite($fpWrite, fread($fpRead, $chunk));
}
fclose($fpWrite);
fclose($fpRead);
网友评论