PHP获取文件夹下的所有目录文件

使用scandir函数

<?
    $path = $_SERVER['DOCUMENT_ROOT']."/excel/logs";
    //此处的$path变量只能使用目录形式的,不能使用域名url形式,否则获取不到。
    $files1 = scandir($path);
    $files2 = scandir($path,1);
    var_dump($files1);
    var_dump($files2);
?>
Array
(
    [0] => .
    [1] => ..
    [2] => bar.php
    [3] => foo.txt
    [4] => somedir
)
Array
(
    [0] => somedir
    [1] => foo.txt
    [2] => bar.php
    [3] => ..
    [4] => .
)


你可能感兴趣的:(文件夹)