What potential problem is identified with the current code when trying to display images from multiple subfolders?

The current code likely only looks for images in a single specified folder, so it will not be able to display images from multiple subfolders. To solve this issue, you can modify the code to recursively scan through all subfolders within the specified directory and display images from each subfolder.

<?php
function displayImagesFromFolder($folder) {
    $files = glob($folder . '/*');
    
    foreach($files as $file) {
        if(is_dir($file)) {
            displayImagesFromFolder($file);
        } else {
            if(preg_match('/\.(jpg|jpeg|png|gif)$/i', $file)) {
                echo '<img src="' . $file . '" alt="Image">';
            }
        }
    }
}

$folder = 'path/to/parent/folder';
displayImagesFromFolder($folder);
?>