PHP Glob: How to use multiple flags with glob function?

南楼画角 提交于 2019-12-13 04:39:23

问题


I want to use both GLOB_NOSORT and GLOB_BRACE with glob() function, is that possible?

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);

Above code will not sort the files according to filemtime().

Thanks


回答1:


Try this:

$files = glob($structure.$filetypes, GLOB_NOSORT | GLOB_BRACE);


来源:https://stackoverflow.com/questions/20351095/php-glob-how-to-use-multiple-flags-with-glob-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!