阅读(1746) (9)

xscandir()

2017-06-30 18:30:28 更新

作用:递归扫描目录并获取目录树。

语法: array xscandir(string $dirname[, int $sort])

参数:

  • $dirname 目录名
  • $sort 排序方式,0(升序,默认),1(降序)

返回值:

  • 返回指定目录的树形结构数组,如果目录名不是一个文件夹,则返回 false

示例:

<?php
print_r(xscandir(__ROOT__.'mod'));
/** 将输出
Array
(
    [0] => .
    [1] => ..
    [classes] => Array
        (
            [0] => .
            [1] => ..
            [2] => category.class.php
            [3] => comment.class.php
            [4] => file.class.php
            [5] => mod.class.php
            [6] => image.class.php
            [7] => mail.class.php
            [8] => database.class.php
            [9] => post.class.php
            [10] => user.class.php
        )
    [common] => Array
        (
            [0] => .
            [1] => ..
            [2] => init.php
            [3] => install.php
            [4] => recover.php
            [5] => update.php
        )
    [config] => Array
        (
            [0] => .
            [1] => ..
            [2] => config.php
            [3] => database.php
            [4] => mime.ini
            [5] => static-uri.php
        )
    [functions] => Array
        (
            [0] => .
            [1] => ..
            [2] => category.func.php
            [3] => comment.func.php
            [4] => common.func.php
            [5] => extension.func.php
            [6] => file.func.php
            [7] => mod.func.php
            [8] => post.func.php
            [9] => user.func.php
        )
    [lang] => Array
        (
            [0] => .
            [1] => ..
            [2] => zh_cn.php
        )
)
*/