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 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

Ask A Question

Stats

  • Questions 537k
  • Answers 537k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's perfectly possible for an RFC 2833 "event" to be… May 17, 2026 at 1:40 am
  • Editorial Team
    Editorial Team added an answer WCF is the recommended approach for cross process communication in… May 17, 2026 at 1:40 am
  • Editorial Team
    Editorial Team added an answer With your project open in Xcode, look in the Groups… May 17, 2026 at 1:40 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

So I have a CSV file that looks like this: 12345, Here is some
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
This is really only easy to explain with an example, so to remove the
I have a YAML document like this: --- version: 1 rootdirectory: - subdirectory: -
I'm trying to parse a file that looks like this: || Column Header A
I'm trying to build an array structured like [ [num, [num, num num]], [num,
Hello future friends who is gonna help me big time on this project, I
I've had to do this many times in the past, and I've never been
I have an array, and I want to make a hash so I can
just want to ask anyone here can solve this problem? I want to create

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.