I have the following multidimensional array in PHP.
For each array(), I have 3 informations for the example. IRL, I have more than 20.
Array
(
[0] => Array
(
[date] => 2019-04-23
[room] => 101
[rate] => 10
)
[1] => Array
(
[date] => 2019-04-25
[room] => 101
[rate] => 10
)
[2] => Array
(
[date] => 2019-04-26
[room] => 101
[rate] => 10
)
[3] => Array
(
[date] => 2019-04-25
[room] => 102
[rate] => 12
)
[4] => Array
(
[date] => 2019-04-26
[room] => 102
[rate] => 12
)
)
Is it possible to group datas from this array but only when the room
and rate
are similars ?
For example, the desire output from the previous array is the following:
Array
(
[0] => Array
(
[room] => 101,
[rate] => 10,
[dates] => Array
(
[0] => 2019-04-23,
[1] => 2019-04-25,
[2] => 2019-04-26
)
)
[2] => Array
(
[room] => 102,
[rate] => 12,
[dates] => Array
(
[0] => 2019-04-25,
[1] => 2019-04-26
)
)
)