Home  >  Article  >  php教程  >  一个目录遍历函数

一个目录遍历函数

WBOY
WBOYOriginal
2016-06-13 12:45:041063browse


一个目录遍历函数
function dirtree($path="./test") {
  echo "

";
  $d = dir($path);
  while(false !== ($v = $d->read())) {
    if($v == "."
$v == "..")
      continue;
    $file = $d->path."/".$v;
    echo "
$v";
    if(is_dir($file))
      dirtree($file);
  }
  $d->close();
  echo "
";
}

dirtree();
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:两种php调用Java对象的方法Next article:生成缩略图