read())){if($v=="."$v=="..") 一个目录遍历函数 更新日期:2026/7/30" />

站长资源网络编程

一个目录遍历函数

整理:jimmy2026/7/30浏览2
简介一个目录遍历函数"; $d = dir($path); while(false !== ($v = $d->read())) { if($v == "." $v == "..")

一个目录遍历函数 <?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();
?>