recursive-dirlisting
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
function ls($dir){
$handle = opendir($dir);
for(;(false !== ($readdir = readdir($handle)));){
if($readdir != '.' && $readdir != '..'){
$path = $dir.'/'.$readdir;
if(is_dir($path)) $output[$readdir] = ls($path);
if(is_file($path)) $output[] = $readdir;
}
}
return isset($output)?$output:false;
closedir($handle);
}
$lijstje = ls('/');
print_r($lijstje);
?>
function ls($dir){
$handle = opendir($dir);
for(;(false !== ($readdir = readdir($handle)));){
if($readdir != '.' && $readdir != '..'){
$path = $dir.'/'.$readdir;
if(is_dir($path)) $output[$readdir] = ls($path);
if(is_file($path)) $output[] = $readdir;
}
}
return isset($output)?$output:false;
closedir($handle);
}
$lijstje = ls('/');
print_r($lijstje);
?>