Home > Backend Development > PHP Tutorial > 关于php显示指定目录下子目录的方法

关于php显示指定目录下子目录的方法

PHPz
Release: 2021-05-31 10:38:24
forward
2231 people have browsed it

这篇文章主要介绍了php显示指定目录下子目录的方法,涉及php操作目录的技巧。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

关于php显示指定目录下子目录的方法

本文实例讲述了php显示指定目录下子目录的方法。分享给大家供大家参考。具体实现方法如下:

<?php
echo "<h2>subdirs in dir</h2><ul>";
$basedir = basename( __FILE__ );
$dirtoscan = ($basedir . &#39;/somedir/&#39;);
$albumlisting = scandir($dirtoscan);
foreach ($albumlisting as $item) {
  $dirinfo = pathinfo($item);
  print_r($dirinfo);
  if (is_dir("$item")) {
   echo "<li><a href=&#39;index.php?subdirs=$item&#39;>$item</a></li>";
  }
}
?>
Copy after login

推荐学习:《PHP视频教程

Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template