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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:46:17+00:00 2026-05-28T05:46:17+00:00

The following function works in PHP > 5.3 but errors out in older versions.

  • 0

The following function works in PHP > 5.3 but errors out in older versions. How can I modify this to make it 5.2 safe?

function _iniloader_get_dirs($dir) {
        $dirs = array_filter(scandir($dir), function ($item) use ($dir) {
            return (is_dir($dir.'/'.$item) && $item != "." && $item != "..");
        });
        // Use array_values to reset the array keys:
        return array_values($dirs);
}

5.2 error:

Parse error: syntax error, unexpected T_FUNCTION … on
line 2

  • 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-28T05:46:17+00:00Added an answer on May 28, 2026 at 5:46 am

    You can easily do it w/o the closure, but you will lose some elegance:

    function _iniloader_get_dirs($dir) {
        $dirs = array();
        $entries = scandir($dir);
        foreach($entries as $item) {
            if($item === '.' || $item === '..') continue;
            if(!is_dir($dir.'/'.$item)) continue;
            $dirs[] = $item;
        }
        return $dirs;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code,the hover function works correctly, but when clicked, loses the clicked_no_event_box
I am trying to make the following recursive function work but keep receiving an
I wrote the following php function to upload files but I'm having a hard
I have the following function which works very well within a $(document).ready(function(){ $('.threadWrapper >
How does the following grep function works (what does !/0o1Iil]/ do? ) @chars =
I used the following function I found online and it works perfectly. However, when
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
I can't get the following function in VBScript to work. I am trying to
The following block of code works fine (no errors) $query = select * from

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.