Jump to content

Archived

This topic is now archived and is closed to further replies.

Tarantulus

Help with directory scan code (beginner)

Recommended Posts

Hi there,
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

Share this post


Link to post
Share on other sites

×

Important Information

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.