Concatenate files in PHP

前端 未结 5 1233
感情败类
感情败类 2021-02-07 18:49

I\'d like to know if there is a faster way of concatenating 2 text files in PHP, than the usual way of opening txt1 in a+, reading txt2 li

5条回答
  •  爱一瞬间的悲伤
    2021-02-07 18:54

    If you want to use a pure-PHP solution, you could use file_get_contents to read the whole file in a string and then write that out (no error checking, just to show how you could do it):

    $fp1 = fopen("txt1", 'a+');
    $file2 = file_get_contents("txt2");
    fwrite($fp1, $file2);
    

提交回复
热议问题