I have some folder structure like this
/photos/1/file1.txt
/photos/2/file2/txt
What i need is to get inside folder photos and get array of all files without path, final array should look like this
$content = ('file1.txt', 'file2.txt');
This is what i have for now, but still not like with final array
function recursive_scandir($dir){
$contents = array();
foreach(scandir($dir) as $file){
if($file == '.' || $file == '..') continue;
$path = $dir.DIRECTORY_SEPARATOR.$file;
if(is_dir($path)){
$contents = array_merge($contents, recursive_scandir($path));
} else {
$contents[] = $path;
}
}
return $contents;
}
print_r(recursive_scandir('photos/'));