I have an array that has the following structure. There are two elements with the exact same date/time the difference is the direction and the value.
Array
(
[0] => Array
(
[date] => 2014-12-09
[time] => 21:58:15
[value] => 4
[in_out] => Outgoing
)
[1] => Array
(
[date] => 2014-12-09
[time] => 21:58:15
[value] => 5
[in_out] => Incoming
)
[2] => Array
(
[date] => 2014-12-09
[time] => 21:57:45
[value] => 5
[in_out] => Outgoing
)
[3] => Array
(
[date] => 2014-12-09
[time] => 21:57:45
[setup_name] => 5
[in_out] => Incoming
)
[4] => Array
(
[date] => 2014-12-09
[time] => 21:57:15
[setup_name] => 3
[in_out] => Incoming
)
[5] => Array
(
[date] => 2014-12-09
[time] => 21:57:15
[value] => 6
[in_out] => Outgoing
)
[6] => Array
(
[date] => 2014-12-09
[time] => 21:56:45
[value] => 6
[in_out] => Outgoing
)
[7] => Array
(
[date] => 2014-12-09
[time] => 21:56:45
[value] => 7
[in_out] => Incoming
)
[8] => Array
(
[date] => 2014-12-09
[time] => 21:56:15
[value] => 4
[in_out] => Outgoing
)
[9] => Array
(
[date] => 2014-12-09
[time] => 21:56:15
[value] => 5
[in_out] => Incoming
)
)
I need get the data into a new array with the following structure:
Array
(
[0] => Array
(
[date] => 2014-12-09
[time] => 21:58:15
[out_value] => 4
[in_value] => 5
)
[1] => Array
(
[date] => 2014-12-09
[time] => 21:57:45
[out_value] => 5
[in_value] => 5
)
[2] => Array
(
[date] => 2014-12-09
[time] => 21:57:15
[out_value] => 6
[in_value] => 3
)
[3] => Array
(
[date] => 2014-12-09
[time] => 21:56:45
[out_value] => 6
[in_value] => 7
)
[4] => Array
(
[date] => 2014-12-09
[time] => 21:56:15
[out_value] => 4
[in_value] => 5
)
)
It would be simple enough if the outgoing/incoming alternated consistently but sometimes there will be two incoming's together (3 and 4).
Any ideas would be appreciated.
Thanks