Answer the question
In order to leave comments, you need to log in
Merge two arrays by keys?
There is the first array:
Array
(
[0] => Array
(
[date1] => 15.08.2016
[money] => 1050
)
[1] => Array
(
[date1] => 11.08.2016
[money] => 5000
)
[2] => Array
(
[date1] => 10.08.2016
[money] => 600
)
Array
(
[0] => Array
(
[date1] => 15.08.2016
[money] => 0
)
[1] => Array
(
[date1] => 14.08.2016
[money] => 0
)
[2] => Array
(
[date1] => 13.08.2016
[money] => 0
)
Array
(
[0] => Array
(
[date1] => 15.08.2016
[money] => 1050
)
[1] => Array
(
[date1] => 14.08.2016
[money] => 0
)
[2] => Array
(
[date1] => 13.08.2016
[money] => 0
)
[3] => Array
(
[date1] => 12.08.2016
[money] => 0
)
[4] => Array
(
[date1] => 11.08.2016
[money] => 5000
)
[5] => Array
(
[date1] => 10.08.2016
[money] => 600
)
Answer the question
In order to leave comments, you need to log in
$merged_normalized =
array_column($arr1, 'money', 'date1') +
array_column($arr2, 'money', 'date1');
$result = [];
foreach ($merged_normalized as $date => $money) {
$result[] = [
'date' => $date,
'money_products_client' => $money
];
}
unset($merged_normalized, $date, $money);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question