国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

PHP獲取目標(biāo)路徑的文件目錄

2023-08-26 19:19 作者:寧哥2022  | 我要投稿

PHP獲取目標(biāo)路徑(圖片目錄)的文件目錄的原生代碼,

寫出來(lái)后發(fā)現(xiàn)還有很大的優(yōu)化空間,但由于是練手的作品沒再深入修改,

但這幾天都有同學(xué)問我這個(gè)問題,所以決定開通博客,并在此獻(xiàn)丑,

若有更優(yōu)方法,也請(qǐng)各位不吝斧正!

閑話少說(shuō),代碼如下:

';

? ? ? ? $str.=$this-> Dloop($val,$newpath,$spaces,$spaces);

? ? ? ? ? ? ? ? ??

? ? ? }

? ? ? else{

? ? ? ? //$str .= '這里寫入樹';

? ? ? ? if(stripos($key,'.jpg')||stripos($key,'.jpeg')){

? ? ? ? ? $fn=''.$key;

? ? ? ? }

? ? ? ? elseif(stripos($key,'.gif')){

? ? ? ? ? $fn=''.$key;

? ? ? ? }

? ? ? ? elseif(stripos($key,'.png')){

? ? ? ? ? $fn=''.$key;

? ? ? ? }

? ? ? ? else{

? ? ? ? ? $fn=''.$key;

? ? ? ? }

? ? ? ? $kb=round(filesize($path.$key)/1024)."k";

? ? ? ? $str.='

';

? ? ? }

? ? }

? return$str;?

? }

}

?>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

classfiles{

? protectedfunctionrefiles($path){

? ? if(file_exists($path)){

? ? ? $ref= scandir($path,1);

? ? ? foreach($refas$val){

? ? ? ? if($val=='.'||$val=='..'){

? ? ? ? ? continue;

? ? ? ? }

? ? ? ? $arr[$val] =is_dir($path.$val)?'folder':'img';

? ? ? }

? ? }

? ? else{

? ? ? $arr= false;

? ? }

? ? return$arr;

? }

? protectedfunctionreall($arr,$path){

? ? foreach($arras$key=>$val){

? ? ? if($val=='folder'){

? ? ? ? $newpath=$path.$key."/";

? ? ? ? $temps=$this->refiles($newpath);

? ? ? ? if($temps){

? ? ? ? ? $newtemp=$this->reall($temps,$newpath);

? ? ? ? ? $arr[$key] =$newtemp;

? ? ? ? }

? ? ? ? else{

? ? ? ? ? $arr[$key] ='null';

? ? ? ? }

? ? ? }

? ? }

? ? return$arr;

? }

? /**

? * 函數(shù)名稱:allfiles()

? * 函數(shù)作用:取得指定路徑下的所有目錄

? * 參數(shù)說(shuō)明:$path:指定的路徑

? * 返 回 值:$result 目錄數(shù)組 or false

? */

? publicfunctionallfiles($path){

? ? $allfiles=$this-> refiles($path);

? ? if($allfiles){

? ? ? $newallfiles=$this-> reall($allfiles,$path);

? ? ? $allfiles=$newallfiles;

? ? }

? ? return$allfiles;

? }

? /**

? * 函數(shù)名稱:Dloop()

? * 函數(shù)作用:雙層循環(huán)取得結(jié)構(gòu)樹

? * 參數(shù)說(shuō)明:$path:指定的路徑

? * 返 回 值:$result 目錄數(shù)組 or false

? */

? publicfunctionDloop($arr,$path,$space=0,$spaces=0){

? ? foreach($arras$key=>$val){

? ? ? if(is_array($val)){

? ? ? ? $spaces+= 15;

? ? ? ? $newpath=$path.$key."/";

? ? ? ? $str.='

'.$key.' '.$kb.' ?

'.$fn.' '.$kb.'

本文來(lái)源:https://www.fushouyu.com/shouyou/195.html

PHP獲取目標(biāo)路徑的文件目錄的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
读书| 孝昌县| 乌拉特后旗| 社旗县| 黄浦区| 丰城市| 玉树县| 珠海市| 炎陵县| 星子县| 高唐县| 潼关县| 辽源市| 南华县| 辉县市| 临沭县| 将乐县| 海口市| 宜兰县| 彰化县| 玉田县| 项城市| 东港市| 华宁县| 宁河县| 迁西县| 日喀则市| 永顺县| 溧水县| 临澧县| 邯郸县| 泰兴市| 朝阳市| 阳谷县| 桃园市| 綦江县| 获嘉县| 连云港市| 木兰县| 新余市| 报价|