function tree(&$arr_file, $directory, $dir_name='')
{
 
    $mydir = dir($directory);
    while($file = $mydir->read())
    {
        if((is_dir("$directory/$file")) AND ($file != ".") AND ($file != ".."))
        {
            tree($arr_file, "$directory/$file", "$dir_name/$file");
        }
        else if(($file != ".") AND ($file != ".."))
        {
            $arr_file[] = "$dir_name/$file";
        }
    }
    $mydir->close();
}
 
//开始运行
$arr_file = array();
tree($arr_file, "D:/mydir");
var_dump($arr_file);

点赞(353)

评论列表共有 0 条评论

立即
投稿
返回
顶部