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


PHP RecursiveIteratorIterator::getGroup方法代码示例

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


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

示例1: run

 /**
  * run() method load specified directory
  *
  * @param array params
  * @return array
  */
 public function run(array $aParams)
 {
     // test of obligatory validated path
     if (isset($aParams['path']) && is_dir($aParams['path']) && (isset($aParams['pattern']) || isset($aParams['extension']))) {
         // init object
         $oDirRecIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($aParams['path']));
         // case of not recursive
         if (isset($aParams['recursive']) === false || isset($aParams['recursive']) === true && $aParams['recursive'] === false) {
             $oDirRecIterator->setMaxDepth(1);
         }
         // clear array
         $this->_aFiles = array();
         // rewind
         $this->rewind();
         $iCount = 0;
         // loop on object result
         while ($oDirRecIterator->valid()) {
             if ($oDirRecIterator->isDot() === false) {
                 // get file name
                 $sFileName = $oDirRecIterator->getFilename();
                 if (isset($aParams['pattern']) && preg_match($aParams['pattern'], $sFileName) || isset($aParams['extension']) && substr(strtolower($sFileName), strrpos($sFileName, '.') + 1) == $aParams['extension']) {
                     $this->_aFiles[$iCount]['path'] = $oDirRecIterator->key();
                     $this->_aFiles[$iCount]['filename'] = $sFileName;
                     // case of subpath
                     if (isset($aParams['subpath']) && $aParams['subpath']) {
                         $this->_aFiles[$iCount]['subpath'] = $oDirRecIterator->getSubPath();
                     }
                     // case of subpathname
                     if (isset($aParams['subpathname']) && $aParams['subpathname']) {
                         $this->_aFiles[$iCount]['subpathname'] = $oDirRecIterator->getSubPathname();
                     }
                     // case of size
                     if (isset($aParams['size']) && $aParams['size']) {
                         $this->_aFiles[$iCount]['size'] = $oDirRecIterator->getSize();
                     }
                     // case of type
                     if (isset($aParams['type']) && $aParams['type']) {
                         $this->_aFiles[$iCount]['type'] = $oDirRecIterator->getType();
                     }
                     // case of owner
                     if (isset($aParams['owner']) && $aParams['owner']) {
                         $this->_aFiles[$iCount]['owner'] = $oDirRecIterator->getOwner();
                     }
                     // case of group
                     if (isset($aParams['group']) && $aParams['group']) {
                         $this->_aFiles[$iCount]['group'] = $oDirRecIterator->getGroup();
                     }
                     // case of time
                     if (isset($aParams['time']) && $aParams['time']) {
                         $this->_aFiles[$iCount]['time'] = $oDirRecIterator->getCTime();
                     }
                     // case of verbose
                     if (isset($aParams['verbose']) && $aParams['verbose']) {
                         echo '[ ', isset($aParams['service']) ? $aParams['service'] : 'FILE', ' ] ', date("d-m-Y à H:i:s"), ' =>  matched file : ', $sFileName, "\n";
                     }
                     ++$iCount;
                 }
             }
             $oDirRecIterator->next();
         }
         // destruct object
         unset($oDirRecIterator);
         // return
         return $this->_aFiles;
     } else {
         // throw exception if specified directory is not declared
         throw new Exception('Specified path or extension or pattern are not declared or is not a valid path');
     }
 }
开发者ID:sho5kubota,项目名称:guidingyou2,代码行数:75,代码来源:dir-reader.class.php


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