实现代码

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, 'e:/web/yun/guiyige/theme/guiyige/');
print_r($arr_file);

运行结果

Array
(
    [0] => /css/animate.min.css
    [1] => /css/bootstrap.min.css
    [2] => /css/flexslider.css
    [3] => /css/font-awesome.min.css
    [4] => /css/main.css
    [5] => /css/responsive.css
    [6] => /fonts/elegant-theme-line.eot
    [7] => /fonts/elegant-theme-line.svg
    [8] => /fonts/elegant-theme-line.ttf
    [9] => /fonts/elegant-theme-line.woff
    [10] => /fonts/flexslider-icon.eot
    [11] => /fonts/flexslider-icon.svg
    [12] => /fonts/flexslider-icon.ttf
    [13] => /fonts/flexslider-icon.woff
    [14] => /fonts/fontawesome-webfont.eot
    [15] => /fonts/fontawesome-webfont.ttf
    [16] => /fonts/fontawesome-webfont.woff
    [17] => /fonts/fontawesome-webfont.woff2
    [18] => /fonts/glyphicons-halflings-regular.eot
    [19] => /fonts/glyphicons-halflings-regular.svg
    [20] => /fonts/glyphicons-halflings-regular.ttf
    [21] => /fonts/glyphicons-halflings-regular.woff
    [22] => /fonts/glyphicons-halflings-regular.woff2
    [23] => /images/portfolio/work-1.jpg
    [24] => /images/portfolio/work-2.jpg
    [25] => /images/portfolio/work-3.jpg
    [26] => /images/portfolio/work-4.jpg
    [27] => /images/portfolio/work-5.jpg
    [28] => /images/portfolio/work-6.jpg
    [29] => /images/slider/slid1.jpg
    [30] => /images/slider/slid2.jpg
    [31] => /index.php
    [32] => /js/bootstrap.min.js
    [33] => /js/jquery.flexslider-min.js
    [34] => /js/jquery.localscroll-1.2.7-min.js
    [35] => /js/jquery.min.js
    [36] => /js/main.js
    [37] => /js/modernizr.js
    [38] => /js/retina.min.js
)