title: Array Merge/Replace
body: <p>I have two arrays:</p>
  
  <pre><code>Array
  (
      [2005] =&gt; 0
      [2006] =&gt; 0
      [2007] =&gt; 0
      [2008] =&gt; 0
      [2009] =&gt; 0
  )
  
  Array
  (
      [2007] =&gt; 5
      [2008] =&gt; 6.05
      [2009] =&gt; 7
  )
  </code></pre>
  
  <p>I want to merge these two arrays such that if a value exists in the 2nd array, it overwrites the first array's value.  So the resulting array would be:</p>
  
  <pre><code>Array
  (
      [2005] =&gt; 0
      [2006] =&gt; 0
      [2007] =&gt; 5
      [2008] =&gt; 6.05
      [2009] =&gt; 7
  )
  </code></pre>
  
  <p>Thanks for your help.</p>
  
  <p>UPDATE:
  This was my best attempt, but it's wildly unsuccessful:</p>
  
  <pre><code>    $final = '';
      foreach ($years as $k =&gt; $v){
          if (in_array($k,$values)){
              $final .= $values[$k] . '|';
          }else{
              $final .= $k[$v] . '|';
          }
  
      }
  
      echo "final = $final";
  </code></pre>