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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:25:19+00:00 2026-05-15T15:25:19+00:00

If, for example, I had array like this: array(34) { [ahostel.lt/img/background.png]=> array(4) { [name]=>

  • 0

If, for example, I had array like this:

array(34) {
  ["ahostel.lt/img/background.png"]=>
  array(4) {
    ["name"]=>
    string(29) "ahostel.lt/img/background.png"
    ["time"]=>
    int(1277819688)
    ["size"]=>
    int(36811)
    ["hash"]=>
    string(32) "2600e98e10aba543fb2637b701dec4f3"
  }
  ["ahostel.lt/img/body-navigation-bg.png"]=>
  array(4) {
    ["name"]=>
    string(37) "ahostel.lt/img/body-navigation-bg.png"
    ["time"]=>
    int(1277819688)
    ["size"]=>
    int(409)
    ["hash"]=>
    string(32) "2e8743f24d46748c5919dfa44b51c2a5"
  }
  ["ahostel.lt/img/calendar-input.gif"]=>
  array(4) {
    ["name"]=>
    string(33) "ahostel.lt/img/calendar-input.gif"
    ["time"]=>
    int(1277819688)
    ["size"]=>
    int(630)
    ["hash"]=>
    string(32) "45d5148e7937fc75a530d7ceb73b7bc8"
  }
  ["ahostel.lt/img/facebook-icon.png"]=>
  array(4) {
    ["name"]=>
    string(32) "ahostel.lt/img/facebook-icon.png"
    ["time"]=>
    int(1277819688)
    ["size"]=>
    int(1090)
    ["hash"]=>
    string(32) "8a76e313b097f53d0f225a5db6f9ae6b"
  }
  ["ahostel.lt/img/favicon.png"]=>
  array(4) {
    ["name"]=>
    string(26) "ahostel.lt/img/favicon.png"
    ["time"]=>
    int(1277819689)
    ["size"]=>
    int(505)
    ["hash"]=>
    string(32) "daa5091eb2c059fc36b54d521e589a50"
  }
[...]

What would be the best sollution to get all directories and files (in separate arrays, though) from a path ahostel.lt/img/. I now have many foreach cycles and this does not look like going towards a good solution.

  • 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-15T15:25:21+00:00Added an answer on May 15, 2026 at 3:25 pm
    $files          = array();
    $directories    = array();
    
    foreach($this->file_system as $key => $file_object_info)
    {
        // make sure this is the requested path and exclude it from appearaning twice
        if(strpos($key, $path) === 0 && $key !== $path)
        {
            $relative_path  = mb_substr($key, mb_strlen($path));
    
            // this is a file
            if(strpos($relative_path, '/') === FALSE)
            {
                $files[$key]        = $file_object_info;
            }
            // this is a directory
            elseif(!substr($relative_path, strpos($relative_path, '/') + 1))
            {
                $directories[$key]  = $file_object_info;
            }
        }
    }
    

    I think this is the farest I can optimize it. It isn’t as bad as I though it will be, though.

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

Sidebar

Related Questions

If for example you had an associative array which looked something like this: $array
For example I have this in a class: private $messages = array( 'name'=> '<aa_f>name',
If I had code like this in Lua, how would I call 'this'? array
I would like to generate a combination of words. For example if I had
Suppose I had a string for example: >>> stri = "日本" >>> res =
If I had an NSDictionary like this: NSMutableDictionary *valuesDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithDouble:-60.0],@a,
I have an array like so: array{ [39] => src=http://www.google.com/jsapi> [111] => src=http://www.example.com/wp-content/themes/code.js [55]
The array looks like this: array( array(5, true, 'Foo'), array(8, true, 'Bar'), array(8, true,
I have an NSDictionary that we will say is like this: key: value: name
Say for example you had a shell script that utilises inotifywait in the following

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.