a.txt
11111111111111111111111111111
222222222222222222222222222222
333333333333333333333333333
444444444444444444444444444444444
5555555555555555555555555555555555
66666666666666666666666666666666
77777777777777777777777777777777
8888888888888888888888888
9999999999999999999999999999999
1010010101011001010101010101101
1111111111111111111111111111111111111111
php实现把a.txt的内容全部复制给b.txt
$arr=file('a.txt');
file_put_contents('b.txt', $arr);
file() 函数把整个文件读入一个数组中。
与 file_get_contents() 类似,不同的是 file() 将文件作为一个数组返回。数组中的每个单元都是文件中相应的一行,包括换行符在内
a.txt 从第二行到第十行的内容复制给c.txt
$arr=file('article.txt');
$c=array_slice($arr, 1,9);
file_put_contents('articlec.txt', $c);
array_slice(array,start,length,preserve)
返回值: 返回数组中的选定部分。