Home > php教程 > php手册 > 遍历某个目录以及其目录的文件

遍历某个目录以及其目录的文件

WBOY
Release: 2016-06-06 19:33:23
Original
959 people have browsed it

遍历某个目录以及其目录的文件,仅用于linux 无 ?phpclass path_list { function dir_list($dir) { if (is_dir ( $dir ) === false) { exit ( '目录路径不存在!' ); } $list = scandir ( $dir ); foreach ( $list as $key = $file ) { if (($file != '.') ($f

遍历某个目录以及其目录的文件,仅用于linux
<?php

class path_list {

 function dir_list($dir) {

 if (is_dir ( $dir ) === false) {

 exit ( '目录路径不存在!' );

 }

 

 $list = scandir ( $dir );

 

 foreach ( $list as $key => $file ) {

 if (($file != '.') && ($file != '..')) {

 if (is_dir ( $dir . '/' . $file )) {

 $row [$file] = $this->dir_list ( $dir . '/' . $file );

 } else {

 $row [$file] = $file;

 }

 }

 }

 

 return $row;

 }

}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template