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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:34:19+00:00 2026-05-27T13:34:19+00:00

i have a multidimensional array whose index/keys (not the values) are like this: this

  • 0

i have a multidimensional array whose index/keys (not the values) are like this:

this is how the submitted array looks

  [param] => Array
            (
                [3] => groupedlista
                [0] => groupedlistb
                [2] => groupedlistc
            )

        [f_name] => Array
            (
                [3] => grouplistaa
                [0] => grouplistbb
                [2] => grouplistcc
            )

        [f_label] => Array
            (
                [3] => grouplistL3
                [0] => grouplistL0
                [2] => grouplistL2
            )

this is how the order looks

0,2,3

i want that Result

  [param] => Array
            (
                [0] => groupedlistb
                [1] => groupedlistc
                [2] => groupedlista
            )

        [f_name] => Array
            (
                [0] => grouplistbb
                [1] => grouplistcc
                [2] => grouplistaa
            )

        [f_label] => Array
            (
                [0] => grouplistL0
                [1] => grouplistL2
                [2] => grouplistL3
            )

that’s it

PS: i use a jquery sort / add / delete feature in the form and i prefer to do the final sorting php-based. the index array [$i] is required to be declared at the form.

  • 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-27T13:34:19+00:00Added an answer on May 27, 2026 at 1:34 pm
    $order = '0,2,3';
    
    $out = array(); // This will hold the sorted values
    $order = explode(',',$order); // Turn the order into an array
    foreach ($multiDimArray as $key => $subArray) { // Loop outer array
      foreach ($order as $pos) { // Loop order array
        if (isset($subArray[$pos])) { // Make sure the key exists
          $out[$key][] = $subArray[$pos]; // Put the correct value in the correct place
        }
      }
    }
    
    print_r($out);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an multidimensional array that looks like this: Array ( [0] => Array
I have a multidimensional array that looks like this [0] => Array ( [recordId]
I have a php multidimensional array which looks like this: $fields = array( array('input',
I have a multidimensional array that looks like this: Array ( [0] => Array
I have a multidimensional array which, when echoed in PHP, looks like this: {
I have a multidimensional array like this: [ 'user 1' => [ ['item 4'
I have a multidimensional array like this: array(2) { [1]=> array(3) { [eventID]=> string(1)
I have this multidimensional array (called $values): Array ( [0] => Array ( [0]
say I have a multidimensional array like this: $data[0]['country'] = Angola $data[0]['report'] = Food
I have a multidimensional array in PHP like this: $array = array( Part1 =>

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.