I have an associative array of data, from which need to group with associative array value.
$data = Array
(
[0] => Array
(
[App] => Array
(
[id] => 12
[user_id] => 121
[skill] => Baking Cakes
)
[Project] => Array
(
[id] => 12
[name] => P1
)
[User] => Array
(
[id] => 121
[name] => Gwoo the Kungwoo
[created] => 2007-05-01 10:31:01
)
),
[1] => Array
(
[App] => Array
(
[id] => 15
[user_id] => 121
[skill] => Baking Cakes
)
[Project] => Array
(
[id] => 13
[name] => P2
)
[User] => Array
(
[id] => 121
[name] => Gwoo the Kungwoo
[created] => 2007-05-01 10:31:01
)
)
)
Is it possible to group above array using User.id using Hash utility? Like this:
Array
(
[121] = Array
(
[0] => Array
(
[App] => Array
(
[id] => 12
[user_id] => 121
[skill] => Baking Cakes
)
[Project] => Array
(
[id] => 12
[name] => P1
)
[User] => Array
(
[id] => 121
[name] => Gwoo the Kungwoo
[created] => 2007-05-01 10:31:01
)
),
[1] => Array
(
[App] => Array
(
[id] => 15
[user_id] => 121
[skill] => Baking Cakes
)
[Project] => Array
(
[id] => 13
[name] => P2
)
[User] => Array
(
[id] => 121
[name] => Gwoo the Kungwoo
[created] => 2007-05-01 10:31:01
)
)
)
)
I tried with few methods Hash::combine(), Hash::extract but couldn't achieve it. Can someone have an idea.
Thanks in advance!
foreachloop.