public static function getFilesArray($root)
{
$alias = array();
$directories = array();
$last_letter = $root[strlen($root) - 1];
$root = $last_letter == '\\' || $last_letter == '/' ? $root : $root . DIRECTORY_SEPARATOR;
$directories[] = $root;
while (sizeof($directories)) {
$dir = array_pop($directories);
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file == '.' || $file == '..' || substr($file, 0, 1) == '.') {
continue;
}
$file = $dir . $file;
if (is_dir($file)) {
$directory_path = $file . DIRECTORY_SEPARATOR;
array_push($directories, $directory_path);
} elseif (is_file($file)) {
$key = basename($file);
$alias[substr($key, 1, strpos($key, '.') - 1)] = $file;
}
}
closedir($handle);
}
}
return $alias;
}