What function can be used in PHP to list all files in a directory?

To list all files in a directory in PHP, you can use the `scandir()` function. This function returns an array of all files and directories in the specified directory. You can then loop through this array to display the list of files.

$directory = "path/to/directory";
$files = scandir($directory);

foreach($files as $file){
    if(is_file($directory . "/" . $file)){
        echo $file . "<br>";
    }
}