php loop through a folder code example
Example: php iterate folder
// Shows us all files and directories in directory except "." and "..".
foreach (new DirectoryIterator('../moodle') as $fileInfo) {
if($fileInfo->isDot()) continue;
echo $fileInfo->getFilename() . "<br>\n";
}