這篇文章主要介紹了php簡單獲取目錄列表的方法,涉及php操作目錄的技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了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程序設計有所幫助。
新聞熱點
疑難解答