09-26-2009, 03:06 PM
|
#3 (permalink)
|
|
The Contributor
Join Date: Apr 2008
Posts: 78
Thanks: 0
|
I'm not sure I understand how to make that change but I tried the following. The result is the same though. The sub-directories are listed but not their contents. This is actually the code I started with but when it didn't work, I added the recursive call to try to get in to the sub-directory.
As for RecursiveDirectoryIterator, I used that first and it did work in some cases. But besides it requiring php 5, the main problem is that it was causing an out of memory condition. That may have been due to the part of the code not shown where the contents of the files are read, but I decided to make it php 4 compatible and switched to the glob function.
PHP Code:
function GetAllFiles(&$files, $locn)
{
$dirs = glob($locn . '/*', GLOB_ONLYDIR);
if(is_array($dirs) && count($dirs) > 0)
{
foreach ($dirs as $dir)
{
foreach (glob($dir . '/*') as $filename)
{
echo 'file '.$filename .'<br>';
$files[] = $filename;
}
}
}
}
|
|
|
|