PHP Glob:如何在glob函数中使用多个标志? [英] PHP Glob: How to use multiple flags with glob function?
本文介绍了PHP Glob:如何在glob函数中使用多个标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想同时使用GLOB_NOSORT
和GLOB_BRACE
和glob()
函数,这可能吗?
I want to use both GLOB_NOSORT
and GLOB_BRACE
with glob()
function, is that possible?
原因是我不希望通过glob()函数进行任何排序,我当前的代码如下:
The reason is I don't want any sorting by glob() function, my current code looks like this:
$filetypes = '{*.txt,*.pdf,*.doc,*.docx,*.zip,*.jpeg,*.jpg,*.gif,*.ping,*.zip,*.rar}';
//assign $files to results of glob()
$files = glob($structure.$filetypes, GLOB_BRACE);
usort($files, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
print_r($files);
以上代码不会按照filemtime()
对文件进行排序.
Above code will not sort the files according to filemtime()
.
谢谢
推荐答案
尝试一下:
$files = glob($structure.$filetypes, GLOB_NOSORT | GLOB_BRACE);
这篇关于PHP Glob:如何在glob函数中使用多个标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文