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程序设计有所帮助。

相关文章

PhpDocumentor 2安装以及生成API文档的方法

官网地址:http://www.phpdoc.org/项目地址:https://github.com/phpDocumentor/phpDocumentor2 phpDocumentor...

PHP实现的获取文件mimes类型工具类示例

本文实例讲述了PHP实现的获取文件mimes类型工具类。分享给大家供大家参考,具体如下: <?php /* * Copyright 2010-2013 Amazon....

在WordPress中实现发送http请求的相关函数解析

在 PHP 中发送 Http 请求(GET / POST)有很多的方法,比如 file_get_contents() 函数、fopen() 函数或者 cURL 扩展,但由于服务器的情况不...

php简单判断文本编码的方法

本文实例讲述了php简单判断文本编码的方法。分享给大家供大家参考。具体如下: 这里通过对文本的一次循环编码,来判断是否属于该编码。 public function chkCode($...

JS 网站性能优化笔记

1. 除去JavaScript注释 除了注释,其他所有的 // or /* */ 注释都可以安全删除,因为它们对于最终使用者来说没有任何意义。 2. 除去JavaScript中的空白区域...