Avatar of ellandrd
ellandrd
Flag for Ireland asked on

split array into groups

I have an array with the following:

Array
(
    [0] => Array
        (
            [PropertyID] => 248
            [UserID] => 28
        )
    [1] => Array
        (
            [PropertyID] => 254
            [UserID] => 28
        )
    [2] => Array
        (
            [PropertyID] => 247
            [UserID] => 28
        )
    [3] => Array
        (
            [PropertyID] => 257
            [UserID] => 30
        )
    [4] => Array
        (
            [PropertyID] => 250
            [UserID] => 4
        )
    [5] => Array
        (
            [PropertyID] => 252
            [UserID] => 3
        )
    [6] => Array
        (
            [PropertyID] => 255
            [UserID] => 4
        )
    [7] => Array
        (
            [PropertyID] => 246
            [UserID] => 31
        )
)

I want to split the array into groups based on the UserID values so my array would output as:

Array
(
    [0] => Array
          (
              [28] => 248
            [28] => 254
            [28] => 247
        )
    [1] => Array
        (
            [30] => 257
        )
    [2] => Array
          (
                [4] => 250
                [4] => 255
            )
      [3] => Array
            (
                  [3] => 252
            )
      [4] => Array
            (
                  [31] => 246
            )
)

Im not sure if the above array structure is correct but you get the idea that I want to split the array into groups....
PHP

Avatar of undefined
Last Comment
ellandrd

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ncoo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ellandrd

ASKER
Both solutions where what I was after as in the result I wanted..

Thanks for your help guys!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23