Home > Backend Development > PHP Tutorial > PHP目录的遍历

PHP目录的遍历

WBOY
Release: 2016-06-23 13:27:15
Original
903 people have browsed it

PHP目录的遍历

<?php //php目录的遍历function showDetail($dirname){$ds = opendir($dirname);while($file = readdir($ds)){$path = $dirname."/".$file;if($file != "." && $file != ".."){  //这里是个坑if(is_dir($path)){showDetail($path);                 //递归调用,如果读出的是目录则继续读取}else{echo $path."<br/>";}}}}$dirname="test";                 //测试一个目录showDetail($dirname);?>
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template