php 列出目录的子目录的解决办法
内容摘要
这篇文章主要为大家详细介绍了php 列出目录的子目录的简单示例,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:
/**
*
对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:
/**
*
文章正文
这篇文章主要为大家详细介绍了php 列出目录的子目录的简单示例,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <code class = "php" > /** * 列出目录的子目录 * * @param * @author php教程 www.idcnote.com **/ function listdir( $dir ){ if ( $handle = opendir( $dir )){ $output = array (); while (false !== ( $item = readdir( $handle ))){ if ( is_dir ( $dir . '/' . $item ) and $item != "." and $item != ".." ){ $output [] = $dir . '/' . $item ; $output = array_merge ( $output , ListDescendantDirectories( $dir . '/' . $item )); } } closedir ( $handle ); return $output ; } else { return false; } } $dirs = listdir( 'myDirectory' ); foreach ( $dirs as $dir ){ echo $dir . '<br>' ; } </code> |
注:关于php 列出目录的子目录的简单示例的内容就先介绍到这里,更多相关文章的可以留意
代码注释