-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunction.php
43 lines (42 loc) · 1.33 KB
/
function.php
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
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* 递归显示目录文件
* @param string $source_dir 目录名
* @param type $directory_depth 深度
* @param type $hidden 是否显示隐藏文件
* @return boolean
*/
function directory_tree($source_dir) {
$realPath = $source_dir;
if ($fp = opendir($realPath)) {
$filedata = array();
// $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
while (FALSE !== ($file = readdir($fp))) {
// Remove '.', '..', and hidden files [optional]
if (!trim($file, '.') OR ( $file[0] == '.')) {
continue;
}
if (is_dir($realPath . '/' . $file)) {
$filedata[] = array(
'isDir' => true,
'name' => $file,
'path' => $source_dir . '/' . $file
);
} else {
$filedata[] = array(
'isDir' => false,
'name' => $file,
'path' => $source_dir . '/' . $file
);
}
}
closedir($fp);
return $filedata;
}
return FALSE;
}