If the files are big, and you know the line number, it'll be something like this: (not tested, you get to do that 🙂 )
$in1 = "abcd";
$in2 = "abcd_1";
$in3 = "abcd_2";
$outfile = "abcd.new";
$brk1 = 123;
$brk2 = 456;
$fp1 = fopen($in1,"r");
$fp2 = fopen($in2,"r");
$fp3 = fopen($in3,"r");
$fpout = fopen($outfile,"w");
// Write the first chunk of the in1 file
for ($i=0;$i<$brk1;$i++){
$buf = fgets($fp1,4096);
fputs($fpout,$buf);
}
// Now insert in2:
while (!feof($fp2)){
$buf = fgets($fp2,4096);
fputs($fpout,$buf);
}
// Now the middle part
for ($i=$brk1+1;$i<$brk2;$i++){
$buf = fgets($fp1,4096);
fputs($fpout,$buf);
}
// Now the in3 file:
while (!feof($fp3)){
$buf = fgets($fp3,4096);
fputs($fpout,$buf);
}
// Now the last part of the main file
while (!feof($fp1)){
$buf = fgets($fp1,4096);
fputs($fpout,$buf);
}
That should do it. Not responsible for any bugs or anything.