Jump to content
MakeWebGames

code not showing all directorys


Recommended Posts

Posted
 
if ($dh = opendir("downloads/")) 
{
   while ($file = readdir($dh))
   {
       if(is_dir($file))
       {
           if (($file <> ".") && ($file <> ".."))
           {
               echo $file;
           }
       }
   }
   closedir($dh);
}

 

i have like 15 directorys in downloads directory. it only shows like 5. why?

Posted
Nope the and (&&) is correct here. The only reason why it would show only a few of the directory is file / directory access rights. Beside that I don't see any other issues.
I tested this myself and it work's.

 

while ($file = readdir($dh)){
if(is_dir($file)){
	if ($file === '.' OR $file === '..'){
		echo $file;
	}
}
}
closedir($dh);

 

Seems to work fine for me. I even set the directory differently of them folder's and it still displayed.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...