當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。