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 3978442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:02:53+00:00 2026-05-20T05:02:53+00:00

I have a question that I haven’t been able to find the answer/script to.

  • 0

I have a question that I haven’t been able to find the answer/script to. I’m just learning to use PHP. I’m using Perch as a CMS and has been going great so far.

I’ve run into a snag when it comes to adding new pages. Something that I want PHP to do is be able to create a dynamic navigation menu for only that directory.

For example, I have three pages in my ‘about’ directory.

root
/about
/index.php
- page2.php
- page3.php

I want to be able to output a side navigation menu based off only that directory.

Home - Page2 - Page3

And when the client/user creates a new page, it’ll automatically add it to the list. So…

root /about /index.php - page2.php - page3.php - newPage.php

…creates…

Home - Page2 - Page3 - New Page

Can anyone point me into a direction of a script or help me get started?

Thanks!

  • 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-20T05:02:53+00:00Added an answer on May 20, 2026 at 5:02 am

    There are quite a few php functions to iterate through directories. I think the cleanest is using PHP SPL (Standard PHP Library)’s Directory Iterator.

    http://www.php.net/manual/en/class.directoryiterator.php

    $dir = new DirectoryIterator('about');
    foreach ($dir as $fileinfo) {
        if (!$fileinfo->isDot()) {
            // Can make the link here
            echo $fileinfo->getFilename();
        }
    }
    

    The advantage is you have a lot of class functions available to you.

    If you need more than the filename you can use:

    • getPathname()
    • getPath()
    • getBasename()
    • isDir()

    And so on… see the docs for all the possibilities.

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

Sidebar

Related Questions

This may be a relatively straight-forward question that I just haven't been searching for
While I have seen this question asked, I haven't seen the answer. I just
I have recently figured out that I haven't been using regex properly in my
I am learning LINQ and have a very simple question that I think will
So I'm learning java, and I have a question. It seems that the types
Question: I have a question that is apparently not answered by this already-asked Bash
From a previous question I have seen that the CLR has workstation and server
I have a question with fluent interfaces. We have some objects that are used
Question So I've recently came up with some new possible projects that would have
Question We have a large number of xml configuration files that we want merged

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.