Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6135435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:28:46+00:00 2026-05-23T17:28:46+00:00

I got a folder structure like so css main.css home layout.css menu.css … account

  • 0

I got a folder structure like so

css
  main.css
  home
    layout.css
    menu.css
    ...
  account
    user.css
    menu.css
      user
        user.css
        level
          time.css
          ...
        ...

You can see a lot of files and folders nested in each other. I want loop through folder css, read every files and folders in it. If a file, run function do(), if a folder run function make() and continue to loop through that folder to check for files and folders inside. Repeat the process until there are no more folder and file left to loop through.

I can easily loop through the files and folders if I know how exactly how many there are. The problem is I don’t know how many folders and files there are. So there need to be a special technique to archive what I want ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:28:46+00:00Added an answer on May 23, 2026 at 5:28 pm

    This would be perfect for the RecursiveDirectorIterator class that comes with PHP. It’ll loop through each file and folder recursively. Each item that you iterate through will be a subclass of SplFileInfo which contains many function you can use (e.g. getBasename(), getCTime(), getExtension(), and many more).

    <?php 
    
    $dir = '/path/to/folder';
    
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
    
    foreach ( $iterator as $path )
    {
      // If it's a directory.
      if ($path->isDir())
      {
        // Do something.
      }
      else
      {
        // Do something else.
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got main folder: c:\test And there I have 2 folders: Movies and Photos.
I've got a folder of images which is reaching a critical mass after a
so in a folder PayPal i've got multiple classes for using their API. i
I've got a couple large checkouts where the .svn folder has become damaged so
I've got an MS-Access database stored in a folder (yes, I have 'Modify' permissions
I've got about 3 million files I need to copy from one folder to
So I've got a nice Java project, build with Ant to a /dist folder.
Simple question: If I've got a generic Error.aspx page in my Shared folder (and
I'm a newbie with WinDbg and got this dump from the WER ReportQueue folder
following is my files directory structure... Config config.php (is calling some files too like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.