问题
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