I have been looking at a bunch of examples throughout Stack Overflow about getting a list of files recursively and storing them in a PHP array. Whatever it is that I am doing wrong is causing the array to be empty. Here is an portion of what I have.
<?php
$mediaFiles = array();
function getFiles() {
$media = "./media";
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($media)) as $filename){
if ($filename->isDir()) continue;
$mediaFiles[] = $filename->getPathname();
}
}
getFiles();
?>
Of course, that is part of it, and not all of it, but it is the relevant portion. I can't seem to figure out the issue, being that I am new to PHP. What am I doing wrong, or is there a better way to do this?
The folder it should be getting the files from has about 800 files in it. So it definitely should not be empty.