title: Create array from foreach loop with key
body: <p>I couldn't quite find the exact solution that I am looking for.</p>
  
  <p>I am trying to create an array from a foreach loop that retains the key.  Here is the code I have so far but it only keeps the last value in the array:</p>
  
  <pre><code>foreach($links as $link) {
    //runs scrape_amazon function for each of the links
    $ret = scrape_amazon($link);
  
    foreach($ret as $key =&gt; $value) {
      //echo $key; 
      //echo $value;
      $final_results[$key] = $value;
    }
  }
  </code></pre>
  
  <p>Could anyone help with a solution to keep all the values and the keys?</p>
  
  <p>Thanks in advance!</p>