$path = "./"; function createDir($path = '.') { if ($handle = opendir($path)) { echo ""; 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 " "; } } function printQueue($queue, $path) { foreach ($queue as $file) { printFile($file, $path); } } function printFile($file, $path) { echo " $file"; } function printSubDir($dir, $path) { echo " $dir"; createDir($path.$dir."/"); echo ""; } createDir($path); ?> 原文地址:http://www.freejs.net/article_jquerywenzi_112.html