I want to combine two arrays using specified deep subarray values.
I have two different arrays with different structures and I want to combine them so that if the "primary keys" match then add second array's values to the first array, if not then create array with array 2's value.
Primary key in first array is [created_by]
and in second array it's [upgrade_by]
Array1 is:
Array(
[0] => Array(
[Customer] => Array(
[created_by] => 5
[amount] => 199
[name] => First Cux
)
)
[1] => Array(
[Customer] => Array(
[created_by] => 1
[amount] => 199
[name] => Last Cux
)
)
)
Array 2 is
Array(
[0] => Array(
[0] => Array(
[refund_amount] => 100
)
[Historycustomer] => Array(
[upgrade_by] => 1
[company] => First Company
)
)
[1] => Array(
[0] => Array(
[refund_amount] => 250
)
[Historycustomer] => Array(
[upgrade_by] => 3
[company] => Last Company
)
)
)
I need result like this:
Array(
[0] => Array(
[Customer] => Array(
[created_by] => 5
[amount] => 199
[name] => First Cux
)
)
[1] => Array(
[Customer] => Array(
[created_by] => 1
[amount] => 199
[refund_mount]=>100
[name] => Last Cux
[company] => First Company
)
)
[2] => Array(
[Customer] => Array(
[created_by] => 3
[refund_mount]=>250
[company] => Last Company
)
)
)
Primary key in first array is [created_by]
and in second array it's [upgrade_by]