Tarantulus
-
Posts
1 -
Joined
-
Last visited
Never
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Help with directory scan code (beginner)
in PHP Coding Help
Posted
I got this code from another site, and I understand how it works, but I can't get the results to display as text.
[code]<?php
function scan_directory_recursively($directory, $filter=FALSE)
{
if(substr($directory,-1) == '/')
{
$directory = substr($directory,0,-1);
}
if(!file_exists($directory) || !is_dir($directory))
{
return FALSE;
}elseif(is_readable($directory))
{
$directory_list = opendir($directory);
while($file = readdir($directory_list))
{
if($file != '.' && $file != '..')
{
$path = $directory.'/'.$file;
if(is_readable($path))
{
$subdirectories = explode('/',$path);
if(is_dir($path))
{
$directory_tree[] = array(
'path' => $path,
'name' => end($subdirectories),
'kind' => 'directory',
'content' => scan_directory_recursively($path, $filter));
}elseif(is_file($path))
{
$extension = end(explode('.',end($subdirectories)));
if($filter === FALSE || $filter == $extension)
{
$directory_tree[] = array(
'path' => $path,
'name' => end($subdirectories),
'extension' => $extension,
'size' => filesize($path),
'kind' => 'file');
}
}
}
}
}
closedir($directory_list);
return $directory_tree;
}else{
return FALSE;
}
}
echo $directory_tree[]
?>[/code]
I've tried echo $directory_list [name];
and such but nothing seems to work, i need the output to have in a javascript expanding menu.
hope this makes sense I am a REAL beginner