Is there a way to glob() only files?
问题 I know that glob can look for all files or only all directories inside a folder : echo "All files:\n"; $all = glob("/*"); var_dump($all); echo "Only directories\n"; $dirs = glob("/*", GLOB_ONLYDIR); var_dump($dirs); But I didn't found something to find only files in a single line efficiently. $files = array_diff(glob("/*"), glob("/*", GLOB_ONLYDIR)); Works well but reads directory twice (even if there are some optimizations that make the second browsing quicker). 回答1: I finally found a