日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php多级遍历,php jquery实现无限级目录遍历展示代码

發布時間:2025/4/5 php 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php多级遍历,php jquery实现无限级目录遍历展示代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前面有講過一個目錄遍歷的例子,這個例子有一點不一樣他可以利用php目錄遍歷出來的目錄或文件進行一個樹型的展示效果。

遍歷出來的效果如下

程序代碼

index.php 里面的jquery文件大家可百度下載一個,因為這是用來實現一個效果的

?代碼如下復制代碼

body

{font: normal 12px arial, tahoma, helvetica, sans-serif;margin:0;background:#fff;padding:30px;}

*{ margin:0; padding:0;}

ul{ visibility:visible; cursor:pointer;}

.simpleTree li{font-size:14px; list-style: none;margin:0 0 0 50px;padding:0 0 0 34px;line-height: 18px;margin-left:-13px;background: url(jquery/images/expandable.gif) 0 -2px no-repeat #fff;}

.simpleTree li span{display:inline;clear: left;white-space: nowrap;}

li.root{padding:0 0 0 20px;line-height:20px;background: url(jquery/images/root.gif) 0 2px no-repeat #fff;}

li.file{padding:0 0 0 35px;line-height:20px;background: url(jquery/images/leaf-last.gif) 0 2px no-repeat #fff;}

$(function(){

$(".simpleTree").children("li").find("ul").hide();

$("span").click(function(){

var $this_ul=$(this).siblings("ul");

if($this_ul.is(":visible")){

$this_ul.stop(false,true).hide();

}else{

$(this).siblings("ul").stop(false,true).show().end().stop(false,true).siblings("ul").find("ul").hide();

}

})

})

include("function.php");

$path="目錄/";//目錄名

echo "

  • 目錄"; //目錄名,和path 中名稱一樣

    list_dir($path);

    echo "

";

?>

function.php 這個文件包含了遍歷目錄的函數了

?代碼如下復制代碼

/*輸出當前目錄下的所有文件數量*/

function files_count($path,? & $i=0){

if($opendir=opendir($path)){

//===============

while($file=readdir($opendir) ){

if($file!="."&&$file!=".."){

if(is_file($path."/".$file)){

$i ;

;

}else{

files_count($path."/".$file, $i);

}

}

}

//=============

return? "(".$i.")";

}

}

//echo files_count("目錄/目錄1/3/");

//=============================//

/*遍歷目錄*/

function list_dir($path){

if($opendir=opendir($path)){

}

echo "

  • ";

while($file=readdir($opendir)){

if($file!="."&&$file!=".."){

if(is_dir($path."/".$file)){

$bar=scandir($path."/".$file);

unset($bar[0]);

unset($bar[1]);

if(count($bar!==0)){

echo "

".$file.files_count($path."/".$file)."";

list_dir($path."/".$file);

}

}else{

echo "

".$file."";

}

}

}

echo "

";

}

?>

總結

以上是生活随笔為你收集整理的php多级遍历,php jquery实现无限级目录遍历展示代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。