Append two text files in PHP

Appending the content from two different text files into a single text file.

Source code :

$file11 = fopen("sample1.txt", 'a+');
$file2 = file_get_contents("sample2.txt");
fwrite($file1, $file2);

Output :

Output is based on user Input file values.
Ex:
sample1.txt contains Hello
sample1.txt contains Hi

Result:Hello Hi

Algorithm :

  1. Open file1.
  2. Get contents from file2.
  3. Write file2 to file 1.

Output :


                

Comments :