想了解一个目录遍历函数的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:|一个|个目|目录|录遍|遍历|历函|函数|数|,下面大家一起来学习吧。
一个目录遍历函数
<?php
function dirtree($path="./test") {
echo "<dl>";
$d = dir($path);
while(false !== ($v = $d->read())) {
if($v == "."
$v == "..")
continue;
$file = $d->path."/".$v;
echo "<dt>$v";
if(is_dir($file))
dirtree($file);
}
$d->close();
echo "</dl>";
}
dirtree();
?>