What is the best practice for checking the existence of multiple files in different folders in PHP?

When checking the existence of multiple files in different folders in PHP, it is best to use a loop to iterate through each folder and file path. This way, you can dynamically check for the existence of each file without hardcoding each path. You can use the `file_exists()` function to check if a file exists at a given path.

$folders = ['folder1', 'folder2', 'folder3'];
$files = ['file1.txt', 'file2.txt', 'file3.txt'];

foreach ($folders as $folder) {
    foreach ($files as $file) {
        $path = $folder . '/' . $file;
        if (file_exists($path)) {
            echo "File $file exists in folder $folder.<br>";
        } else {
            echo "File $file does not exist in folder $folder.<br>";
        }
    }
}