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
https://forums.phpfreaks.com/topic/259267-directory-name/
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
https://forums.phpfreaks.com/topic/259267-directory-name/#findComment-1329151
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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