php显示当前文件所在的文件以及文件夹所有文件,树形展开
XML/HTML Code
- <div id="jQ-menu">
- <?php
- $path = "./";
- function createDir($path = '.')
- {
- if ($handle = opendir($path))
- {
- echo "<ul>";
- while (false !== ($file = readdir($handle)))
- {
- if (is_dir($path.$file) && $file != '.' && $file !='..')
- printSubDir($file, $path, $queue);
- else if ($file != '.' && $file !='..')
- $queue[] = $file;
- }
- printQueue($queue, $path);
- echo "</ul>";
- }
- }
- function printQueue($queue, $path)
- {
- foreach ($queue as $file)
- {
- printFile($file, $path);
- }
- }
- function printFile($file, $path)
- {
- echo "<li><a href="".$path.$file."">$file</a></li>";
- }
- function printSubDir($dir, $path)
- {
- echo "<li><span class="toggle">$dir</span>";
- createDir($path.$dir."/");
- echo "</li>";
- }
- createDir($path);
- ?>
- </div>
原文地址:http://www.freejs.net/article_jquerywenzi_112.html