Jump to content

Recommended Posts

Valid flags:

 

    * GLOB_MARK - Adds a slash to each directory returned

    * GLOB_NOSORT - Return files as they appear in the directory (no sorting)

    * GLOB_NOCHECK - Return the search pattern if no files matching it were found

    * GLOB_NOESCAPE - Backslashes do not quote metacharacters

    * GLOB_BRACE - Expands {a,b,c} to match 'a', 'b', or 'c'

    * GLOB_ONLYDIR - Return only directory entries which match the pattern

    * GLOB_ERR - Stop on read errors (like unreadable directories), by default errors are ignored.

 

From the glob manaul. Add the GLOB_ONLYDIR as the second parameter to your glob to get only directories.

Link to comment
https://forums.phpfreaks.com/topic/155881-counting-folders/#findComment-820518
Share on other sites

Ok, take a step back and what do you want, as I do not think you know.

 

You want to count the directories but now you want it to pull out file names? You are contradicting yourself.

 

<?php

$dir = "modules/";
$dirCount = count(glob($dir, GLOB_ONLYDIR));
echo "Number of directories under {$dir} is {$dirCount}<br />";

foreach (glob($dir . "*") as $filename) {
    echo $filename . "<br />";
}

?>

 

So if that is not what you want, what exactly do you want? As I took it from this:

I hav a script I use to count files but now I want to minipulate it to count folders

 

Tells me that the above code I just posted solves your problem...

Link to comment
https://forums.phpfreaks.com/topic/155881-counting-folders/#findComment-820539
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.