I want to modify this PHP code to do a recursive search and display of an image in one known directory with an unknown number of subdirectories.
Here is the code I have that scans a single directory and iterates over files in html:
<?php
foreach(glob('./img/*.jpg') as $filename)
{
echo '<img src="'.$filename.'"><br>';
}
?>
Given that the base directory $base_dir="./img/";contains subdirectories with unknown amounts and levels of their own subdirectories, all of which include only .jpg files.
In principle, you need to build an array of all the subdirectory paths.
source
share