Well, that's pretty vague, but I'm assuming you don't yet have a file list for all .txt files. So:
Open the directory using something like this:
$path = "."; // Current directory
$dir_handle = @opendir($path) or die("Unable to open $path");
Then go through each file using
while ($file = readdir($dir_handle)) { }
You can use a conditional statement to make sure the extension is .txt:
if (substr($file,strlen($file)-3)=="txt") { }
Substr is just used to get a part of the string, while strlen is used to get the length of the filename.
Inside this conditional statement, you want to write a list of filenames to echo. You can use an array to do this:
$filearray[] = $file;
Close your directory:
closedir($dir_handle);
Now, loop through the array $filearray.
for ($i=0;$i<count($filearray);$i++) { }
With this, you can open and read the contents of each file. There are several methods to do this, but I'd recommend using include() (unless you really want to use fopen, fread, fclose).
include($path.$file);
If you need help putting this all together, just say so. 🙂