一个目录遍历函数

2019-11-17,,

一个目录遍历函数

<?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();
?>

《一个目录遍历函数.doc》

下载本文的Word格式文档,以方便收藏与打印。