rendered paste body<?// Initialise empty array, otherwise an error occurs$folders = array();function recursive_subfolders($folders) { // Set path here $path = dirname(__FILE__); // Create initial "Folders" array if ($dir = opendir($path)) { $j = 0; while (($file = readdir($dir)) !== false) { if ($file != '.' && $file != '..' && is_dir($path.$file)) { $j++; $folders[$j] = $path . $file; } } } closedir($dir); // Then check each folder in that array for subfolders and add the subfolders to the "Folders" array. $j = count($folders); foreach ($folders as $folder) { if ($dir = opendir($folder)) { while (($file = readdir($dir)) !== false) { $pathto = $folder. '/' . $file; if ($file != '.' && $file != '..' && is_dir($pathto) && !in_array($pathto, $folders)) { $j++; $folders[$j] = $pathto; $folders = recursive_subfolders($folders); } } } closedir($dir); } sort($folders); return $folders;}$folders = recursive_subfolders($folders);print_r($folders);?>