zoukankan      html  css  js  c++  java
  • PHP scandir() 函数

    ------------恢复内容开始------------

    实例

    列出 images 目录中的文件和目录:

    <?php
    $dir = "/images/";

    // Sort in ascending order - this is default
    $a = scandir($dir);

    // Sort in descending order
    $b = scandir($dir,1);

    print_r($a);
    print_r($b);
    ?>

    结果:

    Array
    (
    [0] => .
    [1] => ..
    [2] => cat.gif
    [3] => dog.gif
    [4] => horse.gif
    [5] => myimages
    )
    Array
    (
    [0] => myimages
    [1] => horse.gif
    [2] => dog.gif
    [3] => cat.gif
    [4] => ..
    [5] => .
    )

    定义和用法

    scandir() 函数返回指定目录中的文件和目录的数组。


    语法

    scandir(directory,sorting_order,context);
    参数描述
    directory 必需。规定要扫描的目录。
    sorting_order 可选。规定排列顺序。默认是 0,表示按字母升序排列。如果设置为 SCANDIR_SORT_DESCENDING 或者 1,则表示按字母降序排列。如果设置为 SCANDIR_SORT_NONE,则返回未排列的结果。
    context 可选。规定目录句柄的环境。context 是可修改目录流的行为的一套选项。

    技术细节

    返回值: 成功则返回文件和目录的数组。失败则返回 FALSE。如果 directory 不是一个目录,则抛出 E_WARNING 级别的错误。
    PHP 版本: 5.0+高佣联盟 www.cgewang.com
    PHP 更新日志: PHP 5.4:新增 sorting_order 常量。

    ------------恢复内容结束------------

  • 相关阅读:
    bashrc的加载
    无奈卸载Clover 转投TotalCommand
    Hash Table Benchmarks
    linux下编译lua
    可变参数的传递问题
    vector 之 find 重载
    Shell统计报表表格生成
    Shell字符串使用十进制转换
    No module named BeautifulSoup
    Multi Thread.
  • 原文地址:https://www.cnblogs.com/yc10086/p/12993780.html
Copyright © 2011-2022 走看看