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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:53:48+00:00 2026-06-01T01:53:48+00:00

I have a url http:// * .com/branch/module/view/id/1/cat/2/etc/3. It becomes. array ( ‘module’=>’branch’, ‘controller’=>’module’, ‘action’=>’view’

  • 0

I have a url http://*.com/branch/module/view/id/1/cat/2/etc/3.

It becomes.

array
(
  'module'=>'branch',
  'controller'=>'module',
  'action'=>'view'
);

next I need to get the params.
Ihave this array.

/*function getNextSegments($n,$segments) {
    return array_slice ( $q = $this->segments, $n + 1 );
}
$params =   getNextSegments(3);
 */
 array ( 0 => 'id', 1 => '1', 2 => 'cat', 3 => '2', 4 => 'etc', 5 => '3' );//params

And i wanna convert it to this one:
array
(
‘id’=>1,
‘cat’=>2,
‘etc’=>3,
);

How i can do this using php function. I know I can do using for or foreach, but I think php has such function , but i cant find it :(.
Thank you.

  class A {
    protected function combine($params) {

        $count = count ( $params );
        $returnArray = array ();

        for($i = 0; $i < $count; $i += 2) {
            $g = $i % 2;
            if ($g == 0 or $g > 0) {
                if (isset ( $params [$i] ) and isset ( $params [$i + 1] ))
                    $returnArray [$params [$i]] = $params [$i + 1];
            }
        }
        return $returnArray;
    }

}

This works normaly. If anybody has better logic for this please help.
Thank you again.

  • 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-06-01T01:53:49+00:00Added an answer on June 1, 2026 at 1:53 am

    PHP does not have a built-in function for this. I would just implement it with explode and a loop, shouldn’t be that hard.

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

Sidebar

Related Questions

I have a url http://domain.com/module/controller/action/get1/value1/?get2=value2&get3=value3 I want to use Mod_Rewrite to change the ?&=
We have url: http://site.com/index.php?action=show $_GET['action'] is used in templates to check value of ?action=
I have a url like: http://skepticalgamer.com/category/slam-the-controller I'd like to strip out category from the
Please help! I'm on PHP. I have an url: ' http://example.com/articles/123a/view ', how do
I have URL like: http://example.com#something , how do I remove #something , without causing
If I have a URL like http://popurls.com/go/msn.com/l4eba1e6a0ffbd9fc915948434423a7d5 , how do I expand it back
Take a very simple case as an example, say I have this URL: http://www.example.com/65167.html
I have a base URL : http://my.server.com/folder/directory/sample And a relative one : ../../other/path How
I have done urlencode of the variable before passing to the URL http://example.com/Restaurants?alias=F%26B But
I have an url like this: http://www.w3schools.com/PHP/func_string_str_split.asp I want to split that url to

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.