常用方法一:读取文件目录
<?php
$dir = "file";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file!="." && $file!="..") {
echo "<a href=file/".$file.">".$file."</a><br>";
}
}
closedir($dh);
}
}
常用方法二:glob方法
<?php
$dirs = glob($tPath . '/*');
foreach ($dirs as $path) {
if (is_dir($path)) {
$path = basename($path);
$dirs_arr[] = $path;
}
}
}
其实一行代码就可以
<?php
$dirs = array_map('basename', glob ('*', GLOB_ONLYDIR))