I would like to iterate through folders and write all the .jpg
files to a array in order to use them in the next step to create a time-lapse slideshow.
Below is the code that I already have, but how can I :
- Write the
$file
to a array? - Access it from
jQuery
for later processing?
My code so far:
<?php
$dir ="files";
$i=0;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir)
);
$jpg_files = new RegexIterator($iterator, '/\.jpg$/'); // Dateiendung ".jpg"
foreach ($jpg_files as $file) {
if (!$file->isFile()) {
continue;
}
# echo $file->getPathname() . "
";
?>
<img src="<?php echo $file;?>"/>
<?php
}