明辉站/网站教程/内容

一个目录遍历函数

网站教程2024-01-25 阅读
[摘要]一个目录遍历函数<?phpfunction dirtree(path="./test") echo "<dl>"; d = dir(path); while(false !== (v = d->read())) if(...

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

……

相关阅读