<div class="codetitle"> <span><a style="CURSOR: pointer" data="91765" class="copybut" id="copybut91765" onclick="doCopy('code91765')"><u>複製程式碼</u></a></span>如下程式碼:</div> <div class="codebody" id="code91765"> <br><div id="jQ-menu"> <br> php <br>$path = "./"; <br>function createDir($path = '.') <br>{ <br>if ($handle = opendir($path)) <br>{ <br>echo "<ul>"; <br>while (false !== ($file = readdir($handle))) <br>{ <br>if (is_dir($path.$file) && $file != '.' && $file != '..') <br>printSubDir($file, $path, $queue); <br>else if ($file != '.' && $file !='..') <br>$queue[] = $file; <br>} <br>printQueue($queue, $path); <br>回顯「</ul>」; <br>} <br>} <br>函數 printQueue($queue, $path) <br>{ <br>foreach ($queue as $file) <br>{ <br>printFile($file, $path) ; <br>} <br>} <br>函數 printFile($file, $path) <br>{ <br>echo "<li><a href="" .></a></li>」; <br>} <br>function printSubDir($dir, $path) <br>{ <br>echo "<li> <span class="toggle">$dir</span>"; <br>createDir($path.$dir."/"); <br>回顯「</li>」; <br>} <br>createDir($path); <br>?</div> </div>