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. Quote Link to comment 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); } } } } ?> Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.