PHP获取一个目录下的文件信息列表
//获取指定目录下的文件列表
//$path 指定的目录,默认为当前目录
//$ifchild 是否显示子目录文件列表,默认不显示
//$curpath 显示当前的路径,默认为从当前目录开始;这个主要是为了显示确定href路径
function openpath($path=".",$ifchild=false,$curpath="."){
$handle = opendir($path);
if($handle){
$file = readdir($handle);
while($file){
if ($file != "." && $file != "..") {
if(is_dir($file)){
if($ifchild){
openpath($path."/".$file,$ifchild,$curpath."/".$file);
}else{
echo "
$file\n";}
}else if($file != basename(__FILE__)){
echo "
$file\n";}else{
echo $file;
}
}
$file = readdir($handle);
}
}
closedir($handle);
}