php遍历目录的所用文件

来源:互联网 发布:淘宝加入游戏专营网址 编辑:程序博客网 时间:2024/05/20 07:58
<?php
$save=array();
function get_all_file($path)
{
    global $save;
    if(is_dir($path))
    {
        if($dir=opendir($path))
        {
            while(false != ($file=readdir($dir)))
            {
                
                if($file=='.' || $file=='..')
                    continue;
                if(is_file($path."/".$file))
                {
                    //print $path."/".$file."<br>";
                    $save[]=$path."/".$file;
                }
                if(is_dir($path."/".$file))
                {                        
                    get_all_file($path."/".$file);
                }    
            }
            closedir($dir);
            
        }
        
    }
    
    return $save;
}
$dir = "/var/www/TP";
print_r (get_all_file($dir));

?>
0 0
原创粉丝点击