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

  • SEARCH
  • Home
  • 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 5933331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:57:30+00:00 2026-05-22T14:57:30+00:00

I was thinking of using RecursiveIteratorIterator to display the top-directories, in my example layout

  • 0

I was thinking of using RecursiveIteratorIterator to display the “top-directories”, in my example layout and puffar, but I cannot get it to work. The structure is as follows:

| images |
  => layout
       =>lab
  => puffar 

and the result is

layout
layout
layout
layout/lab
layout/lab
puffar
puffar


$directory = 'images';

    $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));

    while($it->valid()) {

    if (!$it->isDot()) {       
        echo $it->getSubPath() . "\n";       
    }

    $it->next();
    }

another thing that I cannot get to work is if I change the directory path to

$directory = 'newsletter.site.se/images';

it is not displaying anything.
It would be fantasic if someone could help me. thanks linda

  • 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-22T14:57:31+00:00Added an answer on May 22, 2026 at 2:57 pm

    Do you really need RecursiveDirectoryIterator if you just want to display the top directories?

    Instead you could use:

    <?php
    foreach (new DirectoryIterator('.') as $entry) {
        if (!$entry->isDot() && $entry->isDir()) {
            echo $entry, '<br />';
        }
    }
    

    If you want all directories, try: (for example)

    <?php
    $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'), RecursiveIteratorIterator::SELF_FIRST);
    foreach ($it as $entry) {
        if ($entry->isDir()) {
            echo $entry, '<br />';
        }
    }
    

    About your second question, have you checked that the path is correct and readable for php?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm thinking about using log4net in a MOSS(SharePoint) 2007 project, but I need to
I was thinking of using a Double as the key to a HashMap but
I'm thinking of using Vagrant to develop Django applications, but I'm a little confused
I was thinking of using TIMESTAMP to store the date+time, but I read that
Thinking of using MinGW as an alternative to VC++ on Windows, but am worried
I'm thinking about using VLC as an ActiveX control for my WPF application, but
I'm using Thinking Sphinx for full-text search, following this video . I'd like to
I am thinking of using a PHP framework called CodeIgniter . One of the
My company are thinking about using Mono for an upcoming product, so we were
I am thinking about using Microsoft Unity for my Dependency Injection tool in our

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.