I was wondering if it was possible to merge two arrays and then override the property of the original array.
$originalArray = [1,2,3];
$newArray = [
'first' => array_merge($originalArray, [4,5]),
'second' => array_merge($originalArray, [6,7]),
];
So what I want to achieve is $originalArray would be [1,2,3], then $newArray['first'] would be [1,2,3,4,5] and then $newArray['second'] would be [1,2,3,4,5,6,7]
Right now, what I have is $originalArray is [1,2,3], then $newArray['first'] is [1,2,3,4,5] and then $newArray['second'] is [1,2,3,6,7] and that makes perfect sense as $originalArray is being merged on both first and second instance but $originalArray is not being overwritten.
I was wondering if that is possible at all? Can we intermediately override the values of $originalArray within $newArray?
array_mergebefore assigning it into$newArray?$newArrayitself.