here is a simple function that iterates a directory recursively and returns as array.
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
function directory_map($source_dir, $top_level_only = FALSE)
{
if ($fp = @opendir($source_dir))
{
//DIRECTORY_SEPARATOR is a constant is different on different Server OS
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$filedata = array(); //let grab all files n directorys into this array
//readdire iterates all the files n folders and returns
while (FALSE !== [...]