当前位置: 首页>>代码示例>>PHP>>正文


PHP DirectoryIterator::getCTime方法代码示例

本文整理汇总了PHP中DirectoryIterator::getCTime方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::getCTime方法的具体用法?PHP DirectoryIterator::getCTime怎么用?PHP DirectoryIterator::getCTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DirectoryIterator的用法示例。


在下文中一共展示了DirectoryIterator::getCTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

<body>
<div class="container-fluid full-height">
    <div class="row full-height">
        <div class="col-md-12 full-height main-frame-container">
            <div class="panel panel-primary main-frame">
                <div class="panel-heading">Package Manager</div>
                <div class="panel-body">
                    <div class="file-detail full-height col-md-4"></div>
                    <div class="file-manager scroll-pane full-height col-md-12">
                        <?php 
$files_array = array();
$dir = new DirectoryIterator(dirname(__FILE__) . "/packages");
while ($dir->valid()) {
    if (!$dir->isDot() && $dir->isDir()) {
        // sort key, ie. modified timestamp
        $key = $dir->getCTime();
        $data = array($dir->getFilename(), dirsize($dir->getPathname()));
        $files_array[$key] = $data;
    }
    $dir->next();
}
ksort($files_array);
$files_array = array_reverse($files_array, true);
foreach ($files_array as $key => $fileinfo) {
    ?>
                                <div class="dir-item" data-package="<?php 
    echo $fileinfo[0];
    ?>
"><a href="?package=<?php 
    echo $fileinfo[0];
    ?>
开发者ID:Geslain,项目名称:Package-manager,代码行数:31,代码来源:index.php

示例2: getListOfFiles

 /**
  *
  * @param <type> $path
  * @param <type> $options
  * @param <type> $throwException
  * @return <type>
  */
 public static function getListOfFiles($path, $options = array(), $throwException = true)
 {
     $list = array();
     $fileName = '';
     if (uFs::is_dir($path, false)) {
         $basePath = $path;
     } else {
         $basePath = dirname($path);
         $fileName = basename($path);
     }
     uFs::is_dir($basePath, true);
     $iterator = new DirectoryIterator($basePath);
     while ($iterator->valid()) {
         $name = $iterator->getFilename();
         if (strlen($fileName) > 0) {
             $pattern = '/^' . $fileName . '/';
             if (1 === preg_match($pattern, $name)) {
                 $fname = $basePath . uFs::DS . $name;
                 $list[] = array('file-name' => $fname, 'date' => $iterator->getCTime());
             }
         } else {
             $fname = $basePath . uFs::DS . $name;
             $list[] = array('file-name' => $fname, 'date' => $iterator->getCTime());
         }
         $iterator->next();
     }
     if (is_array($options) && !empty($options)) {
         if (isset($options['sort-by'])) {
             $sortBy = $options['sort-by'];
             if (isset($options['sort-order'])) {
                 $sortOrder = $options['sort-order'] == 'ASC' ? SORT_ASC : SORT_DESC;
             } else {
                 $sortOrder = SORT_ASC;
             }
             foreach ($list as $key => $row) {
                 $sortArray[$key] = $row[$sortBy];
             }
             array_multisort($sortArray, $sortOrder, $list);
         }
     }
     $result = array();
     foreach ($list as $rec) {
         $result[] = $rec['file-name'];
     }
     return $result;
 }
开发者ID:hglattergotz,项目名称:uUtilitiesPlugin,代码行数:53,代码来源:uDbBackup.class.php


注:本文中的DirectoryIterator::getCTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。