title: How to update an multi-dimensional array based on its original array without overriding current array items?
body: <p>Given $duplicateArray which is copy of $originalArray.
  In $duplicateArray - only 'dynamic' values are allowed to change by user.</p>
  <p>If the $originalArray changes , ie-</p>
  <ul>
  <li>New Section is added</li>
  <li>New Key is added to existing section</li>
  <li>Static/dynamic value is changed</li>
  </ul>
  <p>How can the $duplicateArray array be changed to only</p>
  <ul>
  <li>Change static value without overriding dynamic value</li>
  <li>Add the new sections</li>
  <li>add the new keys</li>
  </ul>
  <p>eg-</p>
  <pre><code>//copy of original with value changed ( key1 dynamic value)
  $duplicateArray= [
      &quot;section1&quot; =&gt; [
        &quot;key1&quot; =&gt; [
          'dynamic'=&gt;'aaa',
          'static'=&gt;'v1',
         ],
      ],
  ];
  </code></pre>
  <pre><code>//original updated with new value
  $originalArray= [
      &quot;section1&quot; =&gt; [
        &quot;key1&quot; =&gt; [
          'dynamic'=&gt;'a',
          'static'=&gt;'v1 new',
         ],
        &quot;key2&quot; =&gt; [
          'dynamic'=&gt;'b',
          'static'=&gt;'v2',
         ],
      ],
      &quot;section2&quot; =&gt; [
        &quot;key1&quot; =&gt; [
          'dynamic'=&gt;'c',
          'static'=&gt;'v3',
         ],
      ]
  ];
  </code></pre>
  <p>Expected $duplicateArray -</p>
  <pre><code>$duplicateArray = [
     &quot;section1&quot; =&gt; [
        &quot;key1&quot; =&gt; [
          'dynamic'=&gt;'aaa',
          'static'=&gt;'v1 new',
         ],
        &quot;key2&quot; =&gt; [
          'dynamic'=&gt;'b',
          'static'=&gt;'v2',
         ],
      ],
      &quot;section2&quot; =&gt; [
        &quot;key1&quot; =&gt; [
          'dynamic'=&gt;'c',
          'static'=&gt;'v3',
         ],
      ]
  ];
  </code></pre>
  <p>Doing- $duplicateArray  = $duplicateArray + $originalArray added the new sections with the keys and contents</p>