首页 > 编程 > PHP > 正文

一个目录遍历函数

2020-02-17 20:20:03
字体:
来源:转载
供稿:网友

一个目录遍历函数<?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();
?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表