Jump to content

directory name


timmah1

Recommended Posts

This script reads a directory, and prints out the name of all directories in the directory that I've chosen

 

This works, but it's only displaying the last 2. Right now, I have 6 directories in the the folder I specified.

 

Can anybody tell me why it does not display all of them?

 

<?php
$path = $_SERVER['DOCUMENT_ROOT']."/panel/api/connectors/sample/projects/";

foreach(glob($path . '*', GLOB_ONLYDIR) as $dir) {
    $dir = basename($dir);
    echo $dir."<br />";
}
?>

 

Thanks in advance

Link to comment
Share on other sites

1) Check the permissions on the directories you are not getting

2) Show us a list of what you expect and what you get

3) Are any of your directories "hidden" (start with a full-stop ("."))?

I'm not sure if glob('*') ignores hidden files or not, seems like I've have trouble with that before.

 

4) try print_r(glob($path . '*', GLOB_ONLYDIR)) before the foreach loop to see what it reports

 

5)  :cry:  :'( :suicide:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.