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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:05:32+00:00 2026-05-26T14:05:32+00:00

The function below returns an array of XML files from a given directory including

  • 0

The function below returns an array of XML files from a given directory including all subdirectories. How can I modify this function by passing a second optional parameter which excludes a directory.

E.g: 
getDirXmlFiles($config_dir, "example2");

Directory/Files
    /file1.xml
    /file2.xml
    /examples/file3.xml
    /examples/file4.xml
    /example2/file5.xml
    /example2/file5.xml

In the above case the function would return all files except files in the example2 directory.

function getDirXmlFiles($base) {        

    $files = array();       
    if(!is_dir($base)) return $files;

    if ($handle = opendir($base)) {
        while (false !== ($file = readdir($handle))) {
            if ($file == "." || $file == "..") continue;

            if(is_dir("$base/$file")) {                 
                $subfiles = $this->getDirXmlFiles("$base/$file");
                $files = array_merge($files, $subfiles);                    
            } else {                    
                if(Cms_File::type($file,false) == "xml") 
                    $files[] = "$base/$file";
            }
        }
        closedir($handle);
    }
    return $files;
}
  • 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-26T14:05:33+00:00Added an answer on May 26, 2026 at 2:05 pm

    Redefine the function inputs:

    function getDirXmlFiles($base, $excludeDir) { 
    

    Then change this line:

    if(is_dir("$base/$file")) { 
    

    to this:

    if(is_dir("$base/$file") && "$base/$file" != "$base/$excludeDir") { 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have php function that parses a xml url and gives me an array.this
I need a function that can return the difference between the below two dates
The function below takes a python file handle, reads in packed binary data from
My function below, will take the values from my custom meta fields (after a
In the PHP function below, I want to exclude cat_ID=1 How can I do
In the function below, I'm seeing to sort the array by alpha. However, it
The below function takes in a array of char pointers Eg : arr[0]: ls
The below function takes an array and checks to see if its keys and
I have this javascript, jquery function, (below) It gets the text inside each table
Can somebody please explain why the below code returns undefined 2 times ? var

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.