最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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ó)家法律
双峰县| 剑阁县| 册亨县| 云霄县| 沙田区| 万荣县| 囊谦县| 治多县| 苍梧县| 梁山县| 勐海县| 忻州市| 贵定县| 太谷县| 东宁县| 新巴尔虎左旗| 望江县| 平阳县| 巧家县| 黄大仙区| 乐平市| 宁陕县| 讷河市| 揭阳市| 环江| 鸡东县| 常熟市| 永福县| 大安市| 玉环县| 西安市| 泽库县| 岳阳市| 裕民县| 视频| 民乐县| 称多县| 商城县| 肃宁县| 大名县| 瑞丽市|