(PHP)在xxx目录中显示可用的文本文件[重复]

This question already has an answer here:

i save edit log in txt files, my problem is how to echo/show all available log/txt files in log directory

im already made function for read file

function readFile($filename) {
    $myfile = fopen("$filename", "r") or die("Unable to open file!");
    // Output one line until end-of-file
    while(!feof($myfile)) {
      echo fgets($myfile) . "<br>";
    }
    fclose($myfile);    
}

above code just function for readfile, my problem is show available files , thanks

</div>

You're looking at using opendir() or the DirectoryIterator class.

Similar question on Stack Overflow.

PHP script to loop through all of the files in a directory?

Should get you going in correct direction.