Return to Snippet

Revision: 18365
at September 29, 2009 07:02 by svenito


Initial Code
function getAllSubdirectories($base) {
	$dir_array = array();
	if (!is_dir($base)) {
		return $dir_array;
	}
		
	if ($dh = opendir($base)) {
		while (($file=readdir($dh)) !== false) {
			if ($file == '.' || $file == '..') continue;
			
			if (is_dir($base.'/'.$file)) {
				$dir_array[] = $file;
			} else {
				array_merge($dir_array, rendertask::getAllSubdirectories($base.'/'.$file));
			}
		}
		closedir($dh);
		return $dir_array;
	}
}

Initial URL


Initial Description
Given a start path will return an array of all subdirectories excluding files

Initial Title
Get all subdirectories of a given directory

Initial Tags
array

Initial Language
PHP