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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:33:02+00:00 2026-05-20T19:33:02+00:00

I have a path like: /blog/2/post/45/comment/24 Can I have an array depends on what

  • 0

I have a path like:

/blog/2/post/45/comment/24

Can I have an array depends on what I have on url, like :

$arr = array('blog'=>'2','post'=>'45','comment'=>'24');

But it should depend on variable passed:

/blog/2 should produce $arr = array('blog'=>'2');

Is this possible to create dynamic array?

  • 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-20T19:33:03+00:00Added an answer on May 20, 2026 at 7:33 pm

    You could try something like this:

    function path2hash($path) {
      // $path contains whatever you want to split
      $chunks = explode('/', $path);
    
      $result = array();
      for ($i = 0; $i < sizeof($chunks) - 1; $i+=2)
        $result[$chunks[$i]] = $chunks[$i+1];
    
      return $result;
    }
    

    You could then use parse_url to extract the path, and this function to turn it into the desired hash.

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

Sidebar

Related Questions

Imagine I have a txt file with a path like: c:\programs\SRC_CODE\ How can I
I have a path string like c:usertesttest.jpg , how can I make it c:\user\test\test.jpg
In python , suppose I have a path like this: /folderA/folderB/folderC/folderD/ How can I
I have a path like C:\application\photo\gallery\sketches . Now I need to check whether this
I have a path like this: parent/child/reply How do I use PHP to remove
I have a long path I'd like to shorten for displaying on a form
I currently have a filesystem path I would like to index into a SQL
If I have a path, like so: c:\windows\system32\inetsrv\abc.exe And I want to make a
I have a full path which I would like to remove certain levels of
So say I have a string like so of a path $path = '/path/to/../../up/something.txt';

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.