How can I get a listing of all files from multiple folders using the PHP glob()
function?
Something like this: glob("data/['folder1', 'folder2']/*");
As described in the documention for glob
, you can expand {a,b,c}
to match a
, b
, or c
as long as you use the GLOB_BRACE
flag.
glob("data/{folder1,folder2}/*", GLOB_BRACE);
If you dont want to specify subdirs then Try:
$all_files = glob("{data/*/*}", GLOB_BRACE);