php1 Posted July 4, 2008 Share Posted July 4, 2008 i have some text files in a folder. is it possible make all text file into one text file using php code. Link to comment https://forums.phpfreaks.com/topic/113195-bhow-to-merge-all-textfiles-in-a-folder-to-one-text-file-using-phpb/ Share on other sites More sharing options...
br0ken Posted July 4, 2008 Share Posted July 4, 2008 <?php $path = "includes/sites/centre/test/"; // Directory containing files $newFile = "includes/sites/centre/test/saturn.php"; // Path to new file $fType = strtolower(substr($newFile, strpos($newFile, "."))); // File type of files to collate (got automatically) $file = @scandir($path); if ($file) { echo "Copying all $fType files from '<b>$path</b>' to '<b>$newFile</b>'<br /><br />"; foreach($file as $file) { if (strlen($file) < 3) continue; if (strtolower(substr($file, strpos($file, "."))) != $fType) continue; if (strtolower($path.$file) == strtolower($newFile)) continue; $f = fopen($path.$file, "r"); if ($f) { $buff = fread($f, filesize($path.$file)); $f = fclose($f); $f = fopen($newFile, "a"); if ($f) { fwrite($f, $buff); $f = fclose($f); } } } } ?> Link to comment https://forums.phpfreaks.com/topic/113195-bhow-to-merge-all-textfiles-in-a-folder-to-one-text-file-using-phpb/#findComment-581632 Share on other sites More sharing options...
php1 Posted August 6, 2008 Author Share Posted August 6, 2008 thank u so much for ur reply . I will try it out and get back to u soon Link to comment https://forums.phpfreaks.com/topic/113195-bhow-to-merge-all-textfiles-in-a-folder-to-one-text-file-using-phpb/#findComment-609521 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Don't bump a topic for no reason (Especially if it's a month (and 2 days) old). Reply if you need to ---------------- Now playing: Foo Fighters - All My Life via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/113195-bhow-to-merge-all-textfiles-in-a-folder-to-one-text-file-using-phpb/#findComment-609522 Share on other sites More sharing options...
php1 Posted August 6, 2008 Author Share Posted August 6, 2008 i want a solution to this quetion. That is why i replied Link to comment https://forums.phpfreaks.com/topic/113195-bhow-to-merge-all-textfiles-in-a-folder-to-one-text-file-using-phpb/#findComment-609523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.