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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:36:48+00:00 2026-06-18T04:36:48+00:00

I have 25 files under 1 folder, which I have included using glob in

  • 0

I have 25 files under 1 folder, which I have included using glob in PHP

    foreach (glob(PATH."*.php") as $filename) {
    require_once $filename; 
    } 

I want to exclude 1 file from this list while testing, how do I achieve that ?
The preg_grep would be difficult to change again and again. What I am trying to achieve is not to mess with the current things and add new files in the folder. I want to exclude the newly added file until it is error free and doesn’t harm the current setup.

  • 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-06-18T04:36:49+00:00Added an answer on June 18, 2026 at 4:36 am

    Specifically exclude the file:

    foreach (glob(PATH."*.php") as $filename) {
      if ($filename!='excluded_file.php') {
        require_once $filename;
      }
    }
    

    If you want to get really sexy:

    $exclude_files=array('exclude1.php','exclude2.php');
    
    foreach (glob(PATH."*.php") as $filename) {
      if (!in_array($filename,$exclude_files)) { require_once $filename; }
    }
    

    Or just temporarily remove the problem file from the directory.

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

Sidebar

Related Questions

I have two files with the same name under the same folder. A file
i have a number of jsp files under web-inf folder. Inside my web.xml i
Is there any way to exclude certain files under the /res folder from being
I have IIS running under Windows XP. I have .html files with classic ASP
I have a following Kohana setup: All my files are placed under 'public_html/koh' My
I have widgets which include both client & and server .coffee files (think of
I have this general project folder of mine which includes a variety of stuff:
I have a php application that has about 50-55 code files. The file that
I have an wordpress setup into /blog folder under my site directory. I have
good day! Let's say that I have a folder named Data which contains multiple

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.