久久久久在线观看_又色又爽又黄的免费视频播放_一区中文字幕_日韩电影在线播放

今日焦點 焦點資訊 營銷之道 企業報道 淘寶運營 網站建設 軟件開發 400電話
  當前位置: 首頁 » 資訊 » 軟件開發 » 正文

幾種php文件夾遍歷的方法

放大字體  縮小字體 發布日期:2018-03-01  來源:企業800網  作者:新格網  瀏覽次數:411  【去百度看看】
核心提示:本文主要和大家分享幾種php文件夾遍歷的方法,希望能幫助到大家。

本文主要和大家分享幾種php文件夾遍歷的方法,希望能幫助到大家。

函數

function dirTree(){
if(!is_dir($path)) return []; $files = []; $dir = opendir($path); while($file = readdir($dir)) { if($file == '.' || $file == '..') continue; $new_path = trim($path, '/').'/'.trim($file, '/'); $files[] = $new_path; if(is_dir($new_path)){ $files = array_merge($files, $this->ergodicDir2($new_path));
}
}
closedir($dir); return $files;
}

Directory類

function dirTree(){
if(!is_dir($path)) return []; $files = []; $dir_h = dir($path); while($file = $dir_h->read()){ if($file == '.' || $file == '..') continue; $new_path = trim($path, '/').'/'.trim($file, '/'); $files[] = $new_path; if(is_dir($new_path)){ $files = array_merge($files, $this->ergodicDir3($new_path));
}
} $dir_h->close(); return $files;
}

迭代器

function dirTree(){
if(!is_dir($path)) return []; $files = []; $dir = new \DirectoryIterator($path); foreach ($dir as $key => $file){ if($file->getFilename() == '.' || $file->getFilename() == '..'){ continue;
} $files[] = $file->getPathname(); if($file->isDir()){ $files = array_merge($files, $this->ergodicDir5($file->getPathname()));
}
} return $files;
}

相關推薦:

PHP文件夾遍歷,圖片等比例壓縮

以上就是幾種php文件夾遍歷的方法的詳細內容,更多請關注php中文網其它相關文章!

 
關鍵詞: php,文件夾,方法
 
[ 資訊搜索 ]  [ 加入收藏 ]  [ 告訴好友 ]  [ 打印本文 ]  [ 違規舉報 ]  [ 關閉窗口 ]

 
0條 [查看全部]  相關評論

 
網站首頁 | 關于我們 | 聯系方式 | 使用協議 | 版權隱私 | 網站地圖 | 排名推廣 | 廣告服務 | 積分換禮 | 網站留言 | RSS訂閱 | 皖ICP備2021004516號-14
企業800網 · 提供技術支持