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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:39:51+00:00 2026-05-13T22:39:51+00:00

i have a multi dimension array with sub array having repeated values of ‘

  • 0

i have a multi dimension array with sub array having repeated values of ‘eduHisRowId‘ like:

Array
(
    [0] => Array
        (
            [eduHisRowId] => 4
            [repOrderId] => 15
        )

    [1] => Array
        (
            [eduHisRowId] => 5
            [repOrderId] => 16
        )

    [2] => Array
        (
            [eduHisRowId] => 5
            [repOrderId] => 17
        )

    [3] => Array
        (
            [eduHisRowId] => 6
            [repOrderId] => 18
        )

    [4] => Array
        (
            [eduHisRowId] => 7
            [repOrderId] => 19
        )

    [5] => Array
        (
            [eduHisRowId] => 7
            [repOrderId] => 20
        )

    [6] => Array
        (
            [eduHisRowId] => 8
            [repOrderId] => 21
        )

)

Now i want sort out these repeated values such that i could be able to check that the record present on index ‘[1] => Array‘ is associated with the record which is present on index ‘[2] => Array‘ & this associated relation will also be in array format like:

Array
    (
        [0] => Array
            (    
                [0] => 4
                [1] => Array
                    (
                        [0] => 15
                    ) 
            )

        [1] => Array
            (
                [0] => 15
                [1] => Array
                    (
                        [0] => 16
                        [0] => 17
                    )
            )

        [2] => Array
            (
                [0] => 6
                [1] => Array
                    (
                        [0] => 18
                    )
            )

        [3] => Array
            (
                [0] => 7
                [1] => Array
                    (
                        [0] => 19
                        [0] => 20
                    )
            )

        [4] => Array
            (
                [0] => 8
                [1] => Array
                    (
                        [0] => 21
                    )
            )

    )

where 0th index of innre mos array will contain ‘eduHisRowId‘ value & the array on 1st index will contain ‘repOrderId‘ values.

Thanks in advance…

  • 1 1 Answer
  • 1 View
  • 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-13T22:39:51+00:00Added an answer on May 13, 2026 at 10:39 pm

    Can I suggest a different solution? What about an array structure that looks like:

    Array
    (
        [4] => Array
               (
                  [0] => 15
               ) 
    
        [5] => Array
               (
                   [0] => 16
                   [1] => 17
               )
     )
    

    The keys are the eduHisRowId values and the value is an array of corresponding repOrderId values.

    Creating this array would go like follows:

    function consolidate($item, $key, $array) {
         $rowId = $item['eduHisRowId'];
         if(!array_key_exists($rowId, $array)) {
             $array[$rowId] = array();
         }
         $array[$rowId][] = $item['repOrderId'];
    }
    
    $result = array();
    
    array_walk($dataArray, 'consolidate', &$result);
    

    $dataArray is your multidimensional array, the resulting array is in $result.

    Reference: array_walk(), array_key_exists()

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

Sidebar

Related Questions

I have a multi-dimension array like: $fields = Array ( [1] => Array (
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
I have a Multi dimension array and what i 'd like to do is
I have a multi-dimension array in php like this $shop = array( array(name,point,number), array('Ranjit',
I have a multi-dimensional array, which basically consists of one sub-array for each year.
I have a multi dimensional array. The only actual values (other than other arrays)
I have an multi-dimensional array that I want to send to a PHP script
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
If I have a multi dimensional array in PHP like so... [0] => Array
I was wandering if I have a multi-dimension array (M*N matrix), how to determine

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.