Merge text files using PHP code
the easiest and best way is to use the below code
<?php $txt1 = file_get_contents('1.txt'); $txt1 .= "\n" . file_get_contents('2.txt'); $txt1 .= "\n" . file_get_contents('3.txt'); $fp = fopen('newText.txt', 'w'); if(!$fp) die('Could not create / open text file for writing.'); if(fwrite($fp, $txt1) === false) die('Could not write to text file.'); echo 'Text files have been merged.'; ?>