10-09-2010, 07:31 PM
|
#2 (permalink)
|
|
The Wanderer
Join Date: Oct 2010
Posts: 9
Thanks: 2
|
hi
i have this script
can you tell me why it not list all file just list one folder and one file.
Script is here
PHP Code:
function dirs($dir){
// set filenames invisible if you want
$invisibleFileNames = array(".", "..", "items.txt", "index.php");
// run through content of root directory
$sfile = scandir($dir);
foreach($sfile as $key) {
// filter all files not accessible
//$path = $rootDir.'/'.$content;
if(!in_array($key, $invisibleFileNames)) {
// if content is file & readable, add to array
if(is_file($key) && is_readable($key)) {
// save file name with path
$allData['file'] = $key;
// if content is a directory and readable, add path and name
}elseif(is_dir($key) && is_readable($key)) {
// recursive callback to open new directory
$allData['dir'] = $key;
}
}
}
return $allData;
}
$my2=dirs('.');
foreach ($my2 as $value) {
echo $value;
}
i want to list seperate directory and seperate file
like
Directory Name:
new folder
newfolder2
FIle Name :
1.jph
2.jpg
Hope SOmeBody will help
|
|
|
|