"Why isn't this code working"
If you go there you will see the entire piece of code that I am trying to get to work.
Here is the source I used...
<?php
function rec($here) {
$entries = array();
if ($handle = opendir($here)) {
while (false !== ($file = readdir($handle))) {
// This section eliminates the current and parent directories from the array
if( $file == '.' || $file == '..' ) {
continue;
} else if (is_dir($here.'/'.$file)) {
// This section adds file names to the array
array_push($entries,'<b>'.$here.'/'.$file.'/</b>');
$tmp = rec($here.'/'.$file);
foreach($tmp as $e) {
array_push($entries,$e);
}
} else if (is_file($here.'/'.$file)) {
// This section adds the subdirectory paths to the array
array_push($entries,$here.'/'.$file);
}
}
closedir($handle);
} else {
echo "<li><b style=\"color:red\">Cannot opendir() $here</b>";
}
return $entries;
}
// The call to the recursive function....
$e = rec($_SERVER['DOCUMENT_ROOT']);
foreach($e as $x) {
echo '<li>'.$x;
}
?>
This works great for displaying the list of subdirectories and the files to the screen.
What I need to do is similar to you in that I want to read and list ONLY zip and text files.
Give this a try and see if it doesn't help.