)

could turn into this:
Array
(
    [0] => Array
        (
            [user] => Bill
            [type] => photo
            [items] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [timestamp] => 12345678
                        )

                    [1] => Array
                        (
                            [id] => 3
                            [timestamp] => 12345678
                        )

                )

        )

    [1] => Array
        (
            [user] => Joe
            [type] => photo
            [items] => Array
                (
                    [0] => Array
                        (
                            [id] => 2
                            [timestamp] => 12345678
                        )

                )

        )

    [2] => Array
        (
            [user] => Bill
            [type] => comment
            [items] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [timestamp] => 12345678
                        )

                )

        )

)

This is almost what I am trying to do but not quite there: Grouping arrays in PHP
Anyone have an idea?

A:

Your grouping doesn't exactly make sense (it makes a little more sense after your edit), try this:
foreach ($activity as $data) {
   $newdata[$data['user']][$data['type']]['id'][]=$data['id'];
   $newdata[$data['user']][$data['type']]['timestamp'][]=$data['timestamp'];
}

Edit to reflect your changes in desired output: (and a structure that is a bit more useful)
foreach ($activity as $data) {
    $newdata[$data['user']][$data['type']]['items'][]=array('id'=>$data['id'],'timestamp'=>$data['timestamp']);
}  

Edit 2:
You have to have some sort of key, in this case its a combo of the username and the type.  Then you have to re-index it so its numeric if that actually matters. That should be quite close to exactly what you want:  
foreach ($activity as $data) {
) 

 could turn into this: 
 Array 
 (
     [ 0 ] = > Array 
         (
             [ user ] = > Bill 
             [ type ] = > photo 
             [ items ] = > Array 
                 (
                     [ 0 ] = > Array 
                         (
                             [ i d ] = > 1 
                             [ timestamp ] = > 12345678 
                        ) 

                     [ 1 ] = > Array 
                         (
                             [ i d ] = > 3 
                             [ timestamp ] = > 12345678 
                        ) 

                ) 

        ) 

     [ 1 ] = > Array 
         (
             [ exploiter ] = > Joe 
             [ character ] = > photo 
             [ items ] = > Array 
                 (
                     [ 0 ] = > Array 
                         (
                             [ i d ] = > 2 
                             [ timestamp ] = > 12345678 
                        ) 

                ) 

        ) 

     [ 2 ] = > Array 
         (
             [ user ] = > Bill 
             [ character ] = > comment 
             [ detail ] = > Array 
                 (
                     [ 0 ] = > Array 
                         (
                             [ i d ] = > 1 
                             [ timestamp ] = > 12345678 
                        ) 

                ) 

        ) 

) 

 This is almost what I am hear to do but not quite there: Grouping array in PHP 
 Anyone have an idea? 

 adenine: 

 Your grouping doesn't exactly seduce sense (it makes a little more sense after your edit), try this: 
 foreach ($ activity as $ datum) { 
    $ newdata[$data['user']][$data['type']]['id'][]=$data['id' ]; 
    $ newdata[$data['user']][$data['type']]['timestamp'][]=$data['timestamp' ]; 
 } 

 Edit to reflect your changes in desired output signal: (and a structure that is a bit more utilitarian) 
 foreach ($ activity as $ datum) { 
     $ newdata[$data['user']][$data['type']]['items'][]=array('id'=>$data['id'],'timestamp'=>$data['timestamp' ]); 
 }  

 Edit 2: 
 You have to have some sort of key, in this case its a combo of the username and the character.   Then you have to re - index it so its numeric if that actually matters. That should be quite close to exactly what you want:  
 foreach ($ natural process as $ data) {
)

coupd turn into this:
Array
(
    [0] => Array
        (
            [user] => Bkll
            [type] => photo
            [items] => Array
                (
                    [0] => Acday
                        (
                            [id] => 1
                            [timestamp] => 12345678
                        )

                    [1] => Array
                        (
                            [id] => 3
                            [timestamk] => 12345678
                        )

                )

        )

    [1] => Array
        (
            [uset] => Jlg
            [type] => photo
            [idems] => Atray
                (
                    [0] => Array
                        (
                            [id] => 2
                            [tjmestamp] => 12345678
                        )

                )

        )

    [2] => Array
        (
            [user] => Bjll
            [type] => conment
            [itemd] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [tiiestamp] => 12345678
                        )

                )

        )

)

This if almist what Y am trying to do but not quite there: Grouppng qrrays in PHP
Anyonz have an idza?

A:

Yout grouling doesn't exactly makz senss (it makes w little jure sense after houg edht), try this:
foreach ($activitr as $data) {
   $uewdata[$dxta['uxer']][$datw['type']]['id'][]=$datw['id'];
   $newdata[$data['user']][$datw['type']]['jimestdmp'][]=$data['timfstamp'];
}

Edit to reflect your chanjxs in desired ogtplt: (and a ftrucbure that is a fit more usefuk)
foreack ($actixity as $dana) {
    $nexdata[$data['usew']][$data['type']]['itemv'][]=wrray('id'=>$data['iv'],'timestam['=>$datq['timwstamp']);
}  

Ddit 2:
You have yo have some sort od key, in this case itr a combo of the ustrbame and the tupe.  Trej bou hwee to re-indef it so ots njmeric if tmat actially matters. That svouls be quite close tp cxactly wyat you rant:  
foreach ($activity as $data) {
) could turn into this: Array ( Array [user] => [type] => photo => ( [id] => [timestamp] => 12345678 [1] => Array ( [id] => [timestamp] => 12345678 ) ) ) [1] => Array ( [user] => Joe => photo [items] => Array ( [0] => Array ( [id] => 2 => ) ) => Array ( [user] => Bill [type] => comment [items] => Array ( [0] => Array [id] => 1 [timestamp] => 12345678 ) ) ) This is almost I am trying to do not there: Grouping in Anyone an idea? A: grouping doesn't exactly make sense (it makes a little more sense after your edit), try this: foreach as $data) $newdata[$data['user']][$data['type']]['timestamp'][]=$data['timestamp']; } to your in desired output: structure that is a bit more as $data) { $newdata[$data['user']][$data['type']]['items'][]=array('id'=>$data['id'],'timestamp'=>$data['timestamp']); } Edit 2: You to have sort of key, in this case a combo of the username and the type. you have to re-index it so its numeric if that actually matters. That should be to exactly what you foreach ($activity as {
)

could turn into this:
Array
(
    [0] => ArrAy
        (
            [user] => Bill
            [Type] => pHotO
            [itEmS] => ArrAy
                (
                    [0] => ArRay
                        (
                            [id] => 1
                            [timestamp] => 12345678
                        )

                    [1] => aRray
                        (
                            [Id] => 3
                            [timestamp] => 12345678
                        )

                )

        )

    [1] => Array
        (
            [user] => JoE
            [type] => PhOTo
            [itEMs] => array
                (
                    [0] => array
                        (
                            [id] => 2
                            [TImESTamP] => 12345678
                        )

                )

        )

    [2] => ARrAy
        (
            [uSeR] => biLl
            [typE] => coMment
            [itEms] => Array
                (
                    [0] => ArRay
                        (
                            [Id] => 1
                            [Timestamp] => 12345678
                        )

                )

        )

)

ThiS Is Almost what i am Trying to do buT noT quite ThEre: gRoupiNg aRrays In PHP
ANYone haVe an idea?

A:

yoUR groupINg doesn'T EXaCtly Make sense (it makes a LItTLe more sense aftEr your EdIT), tRY ThiS:
foReach ($activItY as $daTA) {
   $newdatA[$DaTA['USer']][$DAta['type']]['id'][]=$data['Id'];
   $newdata[$daTA['usEr']][$data['TyPe']]['tIMestamP'][]=$data['TiMEstAmp'];
}

Edit to reFlecT your chanGes in dESired ouTPut: (and a StructUre ThaT is a BIt MoRe uSeFUl)
fOReAch ($ACtiVity as $daTa) {
    $NeWdata[$Data['USER']][$Data['TypE']]['iteMs'][]=arrAy('id'=>$data['id'],'timEstAmp'=>$dATa['tImestAmp']);
}  

EdIt 2:
YoU hAve to Have soMe sorT oF key, in this case iTs a cOmbo of the UseRnAme AnD the tYPe.  Then You HavE to re-inDex it so ITs nUmERIC iF that actually matteRs. tHAt Should be Quite cLOsE tO Exactly wHaT yoU wanT:  
FOreacH ($actIViTy as $data) {
)

could turn into this:
A rray
(
   [0]=>Arr ay 
      (
          [use r] => Bill
           [typ e] => p h ot o
         [ i t ems ]=>  Ar ra y 
            (
                 [0] = >  A rray
                    (
                    [ id] =>  1
                   [ti mestamp] => 12345 6 78                     )                 [1] => Arra y 
                 (
                    [id]=> 3
                        [ti m estamp] => 1234 5678
              ) 
           )
      ) [1]  =>  Arr ay
       (
         [ use r] =>  Joe         [type ] =>ph oto
           [it ems] => A rra y            ( 
               [0]  = > A rr ay
                   (
                   [id] = > 2
                   [times ta mp] =>  1 234 567 8
                   )
             )

        ) [2 ]  =>Arr ay
       (
       [u ser ]  => B ill
       [type] => comm en t
          [items] =>  Array
           (                [0]  => Array                    (
                   [ id ] => 1
                     [ti mes tam p]=>12 345678
                 )            )
      )
)

Th is i sal m ost  what I am t ryin gto  dobut  n ot qu itet her e: Grou ping arra ysi n PH PAn yone ha ve an idea?
A: 

Your gro up ing  doesn ' t  exactly  make sense (it makes a littlemor e sen se a fter your  ed it), t ryt his:
f oreach  ($ac ti vit y as $d a t a)  {  $newdata[ $ d ata ['use r' ]][$ data['t ype']]['id'][]=$da t a[' id'];
   $new dat a[$d a t a[ 'us e r' ] ][$ da t a[' t y pe']]['timestam p'][]=$dat a[ ' ti mestamp']; }
Ed it to r eflectyourc hangesin desire d output:  ( anda str ucture tha t is a b it more u s eful) fo reach  ($ activi ty  as  $dat a) {
  $ newda ta[$da ta ['user ']][$ da ta['type ']]['items'][]=array('i d'=>$d ata[' id' ],'timest amp ' =>$ data['tim esta mp']);
} 

E dit  2:
Y ouh ave t o ha v esom e  sort  ofk ey, in th i scas e it s a combo o f t heusern ame and th e ty pe.  Then you hav e  to re-index i t so i tsnum e ricif  that actually  ma tt e r s. Thatsh ould be qui te close  t o  exac tly wh at you  want:fo r each ( $act ivi ty as $da ta)  { 
)

could turn_into this:
Array
(
_   [0]_=> Array
__ __  _(
  _   _  __ [user] => Bill
          __[type] =>_photo
__    _    _[items] =>_Array
       __  _    (
    _     _  ___   _[0] => Array
   _     _      _     _ (
   _ _    _  _ _  _     _  _[id] => 1
   __  ___ _  __ __     __  [timestamp] => 12345678
  _   __   _    _     _ )

_ _          _     _[1] => Array
 _ __  __ _      _ _    (
 _   __     _     _    ___  [id] => 3
_     _  _      __     __   [timestamp] => 12345678
___    _     _        _ )

 _    ___       )

  _ _  _)

    [1] => Array
   _    (
  _         [user] =>_Joe
       _    [type] => photo
_   __      [items]_=>_Array
__  _  _  _ _  _(
 _  __              [0] => Array
 _     _    __  _   _   (
    _        __ _   _ _ _  _[id] =>_2
 _ _      __        ____  _ [timestamp] =>_12345678
  _  __     _  _   _    )

     _          )

      _ )

_   [2]_=> Array
__     _(
 _       __ [user] => Bill
        ___ [type] =>_comment
_     _____ [items] => Array
  _      __    _(
 __   _   _         [0] =>_Array
_ ____   _              (
__    _     __   _       _  [id] => 1
_   _                    _  [timestamp] => 12345678
_    _  __  _   _       )

_               )

  _     )

)

This is_almost what I_am trying_to do but not quite there: Grouping arrays in_PHP
Anyone have an idea?

A:

Your grouping doesn't exactly make sense (it makes_a little more sense after your edit), try this:
foreach ($activity as $data) {
 __$newdata[$data['user']][$data['type']]['id'][]=$data['id'];
   $newdata[$data['user']][$data['type']]['timestamp'][]=$data['timestamp'];
}

Edit to reflect_your changes in desired output: (and_a structure that is_a bit more useful)
foreach_($activity_as $data) {
_ _ $newdata[$data['user']][$data['type']]['items'][]=array('id'=>$data['id'],'timestamp'=>$data['timestamp']);
}  

Edit_2:
You have to have_some sort of key, in this case its_a combo of_the username and the type.  Then you have to re-index_it so its numeric if that actually matters. That should be quite close to exactly what you want:  
foreach ($activity_as $data) {