function &mapTreeMultiple($directory, $maxrecursion = 0, $count = 0)
{
$retval = array();
$count++;
/* strip trailing slashes */
$directory = preg_replace('![\\\\/]+$!', '', $directory);
if (is_readable($directory)) {
$dh = opendir($directory);
while (false !== ($entry = @readdir($dh))) {
if ($entry != '.' && $entry != '..') {
array_push($retval, $entry);
}
}
closedir($dh);
}
sort($retval);
while (list($key, $val) = each($retval)) {
$path = $directory . "/" . $val;
if (!is_array($val) && is_dir($path)) {
unset($retval[$key]);
if ($maxrecursion == 0 || $count < $maxrecursion) {
$retval[$val] =& File_Find::mapTreeMultiple($path, $maxrecursion, $count);
}
}
}
return $retval;
}