本文實例講述了php簡單獲取目錄列表的方法。分享給大家供大家參考。具體實現方法如下:
<?php
function list_directory_content($dir){
if(is_dir($dir)){
if($handle = opendir($dir)){
while(($file = readdir($handle)) !== false){
if($file != '.' && $file != '..' && $file != '.htaccess'){
echo '<a target="_blank" href="'.$dir.$file.'">'
.$file.'</a><br>'."\n";
}
}
closedir($handle);
}
}
}
?>
希望本文所述對大家的php程序設計有所幫助。