Я пытаюсь просмотреть все файлы в каталоге, и если есть каталог, просмотрите все его файлы и так далее, пока не будет больше каталогов. Каждый обработанный элемент будет добавлен в массив результатов в приведенной ниже функции. Это не работает, хотя я не уверен, что я могу сделать/что я сделал не так, но браузер работает безумно медленно, когда этот код ниже обрабатывается, любая помощь приветствуется, спасибо!
код:
function getDirContents($dir){
$results = array();
$files = scandir($dir);
foreach($files as $key => $value){
if(!is_dir($dir. DIRECTORY_SEPARATOR .$value)){
$results[] = $value;
} else if(is_dir($dir. DIRECTORY_SEPARATOR .$value)) {
$results[] = $value;
getDirContents($dir. DIRECTORY_SEPARATOR .$value);
}
}
}
print_r(getDirContents('/xampp/htdocs/WORK'));