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

yipeiwu_com6年前PHP代码库

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

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

希望本文所述对大家的php程序设计有所帮助。

相关文章

php字符串替换函数substr_replace()用法实例

本文实例讲述了php字符串替换函数substr_replace()用法。分享给大家供大家参考。具体分析如下: substr_replace用于在指定字符串中替换指定位置的子字符串 &...

PHP编程实现阳历转换为阴历的方法实例

本文实例讲述了PHP编程实现阳历转换为阴历的方法。分享给大家供大家参考,具体如下: php类 <?php /** * Class Lunar * 农历 节气 节日...

PHP Zip压缩 在线对文件进行压缩的函数

复制代码 代码如下: /* creates a compressed zip file */ function create_zip($files = array(),$destinat...

在Windows系统下使用PHP生成Word文档的教程

在Windows系统下使用PHP生成Word文档的教程

准备工作 首先,请确保在你的Windows系统中已经安装并配置好了一个典型的WAMP环境。由于Interop纯粹是一个Windows的特性,我们将在Windows平台下搭建Apache和...

PHP扩展模块memcached长连接使用方法分析

      网上广泛流传着一篇文章,讲述php的两个扩展模块memcache和memcached的区别,其中特意强调了memcached...