使用scandir函数
<? $path = $_SERVER['DOCUMENT_ROOT']."/excel/logs"; //此处的$path变量只能使用目录形式的,不能使用域名url形式,否则获取不到。 $files1 = scandir($path); $files2 = scandir($path,1); var_dump($files1); var_dump($files2); ?> Array ( [0] => . [1] => .. [2] => bar.php [3] => foo.txt [4] => somedir ) Array ( [0] => somedir [1] => foo.txt [2] => bar.php [3] => .. [4] => . )
转载于:https://blog.51cto.com/okowo/1282383