Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cakePHP读取文件夹目录并仅显示某些文件类型_Php_File_Cakephp_Directory - Fatal编程技术网

cakePHP读取文件夹目录并仅显示某些文件类型

cakePHP读取文件夹目录并仅显示某些文件类型,php,file,cakephp,directory,Php,File,Cakephp,Directory,在列出文件夹中的所有文件时,我不希望显示任何.db文件 这是我的密码: $ticketId = 100; $uploadPath = Configure::read('Config.uploadPath').'/support_tickets/'; $dir = new Folder($uploadPath.$ticketId); $fileList = $dir->read(true, array('*.db')); 现在$fileList存储所有文件 如何正确编写语句?我将尝试$fi

在列出文件夹中的所有文件时,我不希望显示任何.db文件

这是我的密码:

$ticketId = 100;
$uploadPath = Configure::read('Config.uploadPath').'/support_tickets/';
$dir = new Folder($uploadPath.$ticketId);
$fileList = $dir->read(true, array('*.db'));
现在$fileList存储所有文件


如何正确编写语句?

我将尝试$files=$dir->find('.*.db',false)

对于这种类型的东西来说是很棒的。这里是SVG文件的基本示例

/**
 * @brief SvgIterator for finding svg files
 */
class SvgIterator extends FilterIterator {
    public function accept() {
        $isSvg = $this->current()->getExtension() == 'svg';
        if(!$isSvg) {
            return false;
        }

        return $this->_getData();
    }

/**
 * @brief method for getting data from the SVG files
 *
 * @return boolean
 */
    protected function _getData() {
        $this->current()->_aspectRatio = SvgConvert::aspectRatio($this->current()->getPathname());

        return true;
    }

/**
 * @brief calculate the aspect ratio of the curret file
 *
 * @return float
 */
    public function aspectRatio() {
        return $this->current()->_aspectRatio;
    }
}
使用方法:

$it = new SvgIterator(
    new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($path)));

$return = array();
for ($it->rewind(); $it->valid(); $it->next()) {
    $file = array(
        'file' => $it->current()->getFilename(),
        'aspect_ratio' => $it->aspectRatio()
    );

    $return[] = $file;
}