首页 > 代码库 > php 遍历目录

php 遍历目录

<?php
header("Content-type: text/html; charset=utf-8"); 
date_default_timezone_set(‘Asia/Shanghai‘);
set_time_limit(30);


tree("./ui");


function tree($directory) {
    echo "$directory"."\n";
    $mydir = dir($directory);
    while($file = $mydir->read()){
        if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!="..")){
            tree("$directory/$file");
        }elseif(($file!=".") AND ($file!="..")){ 
            echo "  $directory/$file"."\n";
        }
    }
    $mydir->close(); 
}



php 遍历目录