Home >Backend Development >PHP Tutorial >一个目录遍历函数_PHP

一个目录遍历函数_PHP

WBOY
WBOYOriginal
2016-06-01 12:38:35825browse

一个目录遍历函数
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注入实例_PHPNext article:substr()函数中文版_PHP