How can I modify the while() loop to output file names, sizes, and creation dates in PHP?

To output file names, sizes, and creation dates in PHP using a while() loop, you can use the opendir() function to open a directory, then loop through the files using readdir() to get each file's information. You can use functions like filesize() and filectime() to get the size and creation date of each file.

$dir = "path/to/directory";

if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file != "." && $file != "..") {
                $filePath = $dir . "/" . $file;
                $size = filesize($filePath);
                $creationDate = filectime($filePath);
                echo "File: $file | Size: $size bytes | Creation Date: " . date("Y-m-d H:i:s", $creationDate) . "<br>";
            }
        }
        closedir($dh);
    }
}