Nemmeno questo funzionava, allora ho trovato questo, che va alla grande
Codice PHP:
function scanDirectories($rootDir) {
// set filenames invisible if you want
$invisibleFileNames = array(".", "..", ".htaccess", ".htpasswd");
// run through content of root directory
$dirContent = scandir($rootDir);
$allData = array();
// file counter gets incremented for a better
$fileCounter = 0;
foreach($dirContent as $key => $content) {
// filter all files not accessible
$path = $rootDir.'/'.$content;
if(!in_array($content, $invisibleFileNames)) {
if(is_dir($path) && is_readable($path)) {
$dirNameArray = explode('/',$path);
$allData[$path]['dirPath'] = $path;
$allData[$path]['dirName'] = end($dirNameArray);
// recursive callback to open new directory
$allData[$path]['content'] = scanDirectories($path);
}
}
}
return $allData;
Sul manuale on-line