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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:56:41+00:00 2026-05-24T05:56:41+00:00

Perhaps I’m over-looking some minor error somewhere, however I have spent 20 minutes staring

  • 0

Perhaps I’m over-looking some minor error somewhere, however I have spent 20 minutes staring at this and re-reading the PHP manual, which is far too long for me to spend on a single line of code.

I am writing a WordPress plugin which is implemented as a class. In my plugin I have the following line:

$choices = glob(dirname(__FILE__)."/images/*.{gif,jpg,jpeg,png}", GLOB_BRACE);

Clearly I want $choices to be an array containing every image in the “images” folder, relative to the included file. The line originally looked like this:

$choices = glob("images/*.{gif,jpg,jpeg,png}", GLOB_BRACE);

However it was returning an array with several images from an entirely different folder (the wp-admin/images folder, to be specific). My best bet is that it’s because the function which calls glob() was itself called by the admin_init hook, which is called by a script in the wp-admin folder. In order to make the search relative to my plugin and not the wp-admin folder I applied the dirname(__FILE__) at the beginning.

My issue now is that I’m getting an empty array. I even tried:

var_dump(dirname(__FILE__)."/images/*.{gif,jpg,jpeg,png}");

to see exactly what was getting passed. The following was returned:

string(79) “/home/coupon/public_html/wp-content/plugins/DE-menu/images/*.{gif,jpg,jpeg,png}”

Which looks just fine to me… As I said, perhaps I’m over-looking something simple. Anyone have any ideas?

  • 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-24T05:56:42+00:00Added an answer on May 24, 2026 at 5:56 am

    Please add the images to your folder!

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

Sidebar

Related Questions

Perhaps it's a syntax error, but I never assume that. I have a -dead-
Perhaps I am getting rusty (have been writing in Python recently). Why does this
Perhaps this is nitpicky, but I have to ask. I'm using Nokogiri to parse
perhaps I'm asking the wrong question. I have code like this: class ExpressionGrammar(Grammar): def
Perhaps I am not asking or searching for this correctly: I want to have
Perhaps any of you can help me with this anoying problem. I have long
Perhaps I'm missing something simple, as I believe that this is a common scenario...
Perhaps this question has been asked elsewhere, but I'm unable to find it. With
Perhaps someone can help me out with this one: I'm using a basic search
Perhaps this has something to do with it being the mainForm, but I'll ask

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.