is_dir trouble
I'm trying to write a small script for a friend that will list all of the directories contained in a directory. My function currently looks like this:
When I call the function like so displayDir(getcwd()); it displays all of the directories correctly. However when I try displayDir("test"); (test is a valid directory on my server which contains 11 other directories) is only reutrns back the . .. and one other directory. I've tried taking out the is_dir condition and it returns all of the files located in test just fine. Any idea what's up?
function displayDir($dir)
{
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
echo "<p>";
foreach($files as $dirName)
{
if(is_dir($dirName))
echo $dirName . "<br>\n";
}
echo "</p>\n";
}When I call the function like so displayDir(getcwd()); it displays all of the directories correctly. However when I try displayDir("test"); (test is a valid directory on my server which contains 11 other directories) is only reutrns back the . .. and one other directory. I've tried taking out the is_dir condition and it returns all of the files located in test just fine. Any idea what's up?
