Return to Snippet

Revision: 52317
at October 19, 2011 23:16 by klovera


Initial Code
function getDirectory($path){
	
        // Directories to ignore when listing output
        $ignore = array( 'cgi-bin', '.', '..' );

	$handle = opendir($path);
	
	$dir_arr = array();
	$i = 0;

        while (false !== ($dir = readdir($handle))) { 
            if( !in_array( $dir, $ignore ) ){ 
                if (is_dir("$path/$dir")) { 
                    $dir_arr[] = $dir;  
                } 
            }
        }  
        
        closedir($handle);

        return $dir_arr;

}

Initial URL


Initial Description
Returns an array of folder names contained within the passed path.

Initial Title
PHP Function: getDirectory

Initial Tags


Initial Language
PHP