Okay, I tried to implement it, but with no luck. I set up the following code:
<?php
$qtype = 0;
$writefile = "namelist.txt";
if ($handle = opendir('data')) {
while (false !== ($datafile = readdir($handle))) {
if ($datafile != "." && $datafile != "..") {
echo "$datafile<br>";
$file_handle = fopen($writefile,"a+");
$file_line = file($datafile);
$filedata = $file_line[0];
if (fwrite($writefile, $filedata) === FALSE) {
echo "Cannot write to file ($writefile)";
exit;
}
echo "Success, wrote ($filedata) to file ($writefile)";
fclose($file_handle);
} else {
echo "The file $writefile is not writable. ";
}
}
closedir($handle);
}
?>
With 'data' being the folder containing the numerous text files I'm trying to read, and 'namelist.txt' being the text file I'm trying to write all that data to, line by line. In running the script, though I get two lines of "The file namelist.txt is not writable. " and then several lines reading in the format of "userjohndoe.txt Success, wrote () to file (namelist.txt)".
But then it stops short, and nothing is actually written to the namelist.txt. It looks like it's not successfully pulling the data from the text files. What am I missing?
Thanks.