I have 2 arrays and I want to push a value from one array to another where keys values equal each other.
1st array
$retail_rates=[
{
"supplier": "ALAMO",
"rateTotalAmount": 293.44,
"estimatedTotalAmount": 495.34, //i want to add this AS retailTotalAmount
"numDays": 9 // i want to add this
},
{
"supplier": "HERTZ",
"rateTotalAmount": 317.16,
"estimatedTotalAmount": 537.43,
"numDays": 9
}
]
2nd array
$net_rates =[
{
"reference_number": "COMPEKYP7537400-2401",
"supplier": "HERTZ",
"rateTotalAmount": 203.01,
"estimatedTotalAmount": 291.21
},
{
"reference_number": "REF_ID:867692955",
"supplier": "ALAMO",
"rateTotalAmount": 147,
"estimatedTotalAmount": 225.58
}
]
What I want to end up with
$final_array=[
{
"reference_number": "COMPEKYP7537400-2401",
"supplier": "HERTZ",
"rateTotalAmount": 203.01,
"estimatedTotalAmount": 291.21,
"retailTotalAmount": 537.43,
"numDays": 9
},
{
"reference_number": "REF_ID:867692955",
"supplier": "ALAMO",
"rateTotalAmount": 147,
"estimatedTotalAmount": 225.58,
"retailTotalAmount": 495.34
"numDays": 9
}
// and so on all the way through
]
I have tried several loops but can't seem to fill it properly. Please help if you can