implementing PHP's array_merge when handling null values in multidimensional arrays
I'm testing a new approach and I'm testing a new approach and I'm running into a question with PHP's `array_merge` function when trying to merge two multidimensional arrays that contain `null` values. I'm using PHP 8.1 and my goal is to combine these arrays while preserving the keys and ensuring that any `null` values are kept intact rather than being ignored or overwritten. Here are the two arrays I'm trying to merge: ```php $array1 = [ 'a' => 1, 'b' => null, 'c' => [ 'd' => 4, 'e' => null ] ]; $array2 = [ 'a' => 2, 'b' => 3, 'c' => [ 'd' => null, 'f' => 5 ] ]; ``` When I use the `array_merge` function like this: ```php $result = array_merge($array1, $array2); ``` I get the following output: ```php [ 'a' => 2, 'b' => 3, 'c' => [ 'd' => null, 'e' => null, 'f' => 5 ] ] ``` As you can see, the value for key `'a'` from `$array1` is overwritten, and key `'b'` is also replaced, while the `null` values for keys `'b'` and `'e'` in `$array1` are not preserved as I expected. I tried using `array_replace_recursive` as well, but it still did not yield the results I need because it also overwrites existing keys. I want to ensure that if a key exists in both arrays, the value should only be updated if it's not `null`, and if both are `null`, then it should remain `null`. Could someone suggest a way to achieve this merge while keeping the specified behavior for `null` values?