目錄遞歸循環(huán)php代碼
來源:程序員人生 發(fā)布時(shí)間:2014-01-26 20:28:13 閱讀次數(shù):3591次
這是一款從代碼和速度上還不錯(cuò)的php目錄遍歷代碼,有需要的朋友可以參考一下。
- $path = '..';
- function get_filetree($path){
- $tree = array();
- foreach(glob($path.'/*') as $single){
- if(is_dir($single)){
- $tree = array_merge($tree,get_filetree($single));
- }
- else{
- $tree[] = $single;
- }
- }
- return $tree;
- }
- print_r(get_filetree($path));
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)