I am trying to merge all files in a dir into one text file with PHP.
All the files are text files and have one word on each line.
I just need to combine them all into one text file with all the words, one on each line.
The files extensions are numbers 0-5 multiples of 5 (.10, .15, .20, .25) and .txt files.
This is what I have so far, but it only makes an empty text file.
<?php
$files = glob("./*.??");
$out = fopen("listTogether.txt", "w");
foreach($files as $file){
$in = fopen($file, "r");
while($line = fread($in)){
fwrite($out, $line);
echo "writing file";
}
fclose($in);
}
fclose($out);
?>
<!Doctype HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>file merger</title>
</head>
<body>
<p>Doo Wop</p>
</body>
</html>