I have a template array:
$templateArray = [
'apple'=>'green',
'bags'=>[['small'=>'1.99'],['medium'=>'2.99'],['large'=>'3.99']]
]
I wish to merge that with what a user passes in:
$userArray = [
'apple'=>'green',
'banana'=>'yellow',
'bags'=>[['large'=>'5000']]
]
I use:
array_intersect_key($userArray, $templateArray);
Which produces:
$processedArray = [
'apple'=>'green',
'bags'=>[['large'=>'5000']]
]
The issue I am having is that I want to merge the multi bags array to produce:
$processedArray = [
'apple'=>'green',
'bags'=>[['small'=>'1.99'],['medium'=>'2.99'],['large'=>'5000']]
]
Is there a way to do this?