I have two arrays (in the foreach loop) that may or may not have the same dynamically generated keys e.g. 298, 184, 182
as in the code sample below.
I want to merge values for the same keys and make a single array.
Note: Arrays are the results within the foreach loop.
Keys are dynamically generated by id and items may or may not be the same in both arrays.
Resulting Arrays in Loop
Array
(
[298] => Array
(
[dates] => Array
(
[0] => 2020-12-26 10:39:13
[1] => 2020-12-15 12:18:23
[2] => 2020-12-22 12:27:46
[3] => 2020-12-24 10:51:00
[4] => 2020-12-26 10:01:44
[5] => 2020-12-26 10:31:55
[6] => 2020-12-26 10:48:33
[7] => 2020-12-26 10:56:34
)
)
[184] => Array
(
[dates] => Array
(
[0] => 2020-11-16 07:52:33
[1] => 2020-12-24 13:01:14
)
)
[182] => Array
(
[dates] => Array
(
[0] => 2021-01-05 08:50:27
)
)
)
Array
(
[298] => Array
(
[dates] => Array
(
[0] => 2020-11-16 07:38:26
[1] => 2020-11-16 07:47:05
[2] => 2020-12-15 12:20:07
[3] => 2020-12-24 10:52:35
)
)
[184] => Array
(
[dates] => Array
(
[0] => 2020-11-16 07:53:12
)
)
)
Expecting Single Array
Array
(
[298] => Array
(
[dates] => Array
(
[0] => 2020-12-26 10:39:13
[1] => 2020-12-15 12:18:23
[2] => 2020-12-22 12:27:46
[3] => 2020-12-24 10:51:00
[4] => 2020-12-26 10:01:44
[5] => 2020-12-26 10:31:55
[6] => 2020-12-26 10:48:33
[7] => 2020-12-26 10:56:34
[8] => 2020-11-16 07:38:26
[9] => 2020-11-16 07:47:05
[10] => 2020-12-15 12:20:07
[11] => 2020-12-24 10:52:35
)
)
[184] => Array
(
[dates] => Array
(
[0] => 2020-11-16 07:52:33
[1] => 2020-12-24 13:01:14
[2] => 2020-11-16 07:53:12
)
)
[182] => Array
(
[dates] => Array
(
[0] => 2021-01-05 08:50:27
)
)
)