This function does the same thing but is a _LOT_ faster:
PHP Code:
function get_dir_iterative($dir = '.', $exclude = array( 'cgi-bin', '.', '..' ))
{
$exclude = array_flip($exclude);
if(!is_dir($dir))
{
return;
}
$dh = opendir($dir);
if(!$dh)
{
return;
}
$stack = array($dh);
$level = 0;
while(count($stack))
{
if(false !== ( $file = readdir( $stack[0] ) ) )
{
if(!isset($exclude[$file]))
{
print str_repeat(' ', $level * 4);
if(is_dir($dir . '/' . $file))
{
$dh = opendir($file . '/' . $dir);
if($dh)
{
print "<strong>$file</strong><br />\n";
array_unshift($stack, $dh);
++$level;
}
}
else
{
print "$file<br />\n";
}
}
}
else
{
closedir(array_shift($stack));
--$level;
}
}
}
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.
Experience is something you get just after you really need it.
PHP Installation Guide Feedback welcome.