PHP tree 我想用php代码动态的将C:/WINDOWS下面的所有文件夹和子文件夹用tree的形式在页面显示,该怎么做啊?最好能发全部的代码,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function listDirTree( $dirName = null ) { if( empty( $dirName ) ) exit( "IBFileSystem: directory is empty." ); if( is_dir( $dirName ) ) { if( $dh = opendir( $dirName ) ) { $tree = array(); while( ( $file = readdir( $dh ) ) !== false ) { if( $file != "." && $file != ".." ) { $filePath = $dirName . "/" . $file; if( is_dir( $filePath ) ) //为目录,递归 { $tree[$file] = listDirTree( $filePath ); } else //为文件,添加到当前数组 { $tree[] = $file; } } } closedir( $dh ); } else { exit( "IBFileSystem: can not open directory $dirName."); } //返回当前的$tree return $tree; } else { exit( "IBFileSystem: $dirName is not a directory."); } }print_r(listDirTree("d:/tools"));返回的数组就是结构 http://www.zzxj.net/blog/fxs_2008/archive/2009/02/12/23.html function readfolder($path) { if ($handle=@opendir($path)) { //echo "a"; while (false!==($file=readdir($handle))) { if ($file<>"." AND $file<>"..") { if (is_file($path.'\\'.$file)) { //@unlink($path.'/'.$file); //echo "<br>".$path.'/'.$file; //$fileArray[] echo $path"."\\".$file; } if (is_dir($path.'\\'.$file)) { $filelist.=readfolder($path.'\\'.$file); } } } } return $filelist;} 如果你的php是5.0以上的话,<?php$dir = "D:\\cc";$handle = new RecursiveDirectoryIterator(new DirectoryIterator($dir));foreach($handle as $vv){ echo $handle->getFileName() . "<br>";}?> 一个正则问题 zend studio 9.0 生成wsdl 在哪? 为什么我的apache服务器只能解析根目录的php程序,下层目录就解析不了 一个搜索中文问题 请给小弟指点一下 请问如何在浏览器上隐藏页面传递的内容 各位大虾,小弟近日被困。。。 如何从数据库中读取固定的数据 用HWiNFO32 V1.22检测机器硬件信息,当检测到“IDE/SCSI Drive(s)”时,硬盘灯常亮并死机,请问是什么原因?是硬件的问题吗? 对二维数组下的数组个数排序问题 求一个..htaccess urlrewrite php有官方的view标签?
function listDirTree( $dirName = null )
{
if( empty( $dirName ) )
exit( "IBFileSystem: directory is empty." );
if( is_dir( $dirName ) )
{
if( $dh = opendir( $dirName ) )
{
$tree = array();
while( ( $file = readdir( $dh ) ) !== false )
{
if( $file != "." && $file != ".." )
{
$filePath = $dirName . "/" . $file;
if( is_dir( $filePath ) ) //为目录,递归
{
$tree[$file] = listDirTree( $filePath );
}
else //为文件,添加到当前数组
{
$tree[] = $file;
}
}
}
closedir( $dh );
}
else
{
exit( "IBFileSystem: can not open directory $dirName.");
}
//返回当前的$tree
return $tree;
}
else
{
exit( "IBFileSystem: $dirName is not a directory.");
}
}print_r(listDirTree("d:/tools"));返回的数组就是结构
{
if ($handle=@opendir($path))
{
//echo "a";
while (false!==($file=readdir($handle)))
{
if ($file<>"." AND $file<>"..")
{
if (is_file($path.'\\'.$file))
{
//@unlink($path.'/'.$file);
//echo "<br>".$path.'/'.$file;
//$fileArray[]
echo $path"."\\".$file;
}
if (is_dir($path.'\\'.$file))
{
$filelist.=readfolder($path.'\\'.$file);
}
}
}
}
return $filelist;
}
{
echo $handle->getFileName() . "<br>";
}?>