title: PHP: How to modify an array from inside foreach loop (by reference)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7733290/how-to-modify-an-arrays-values-by-a-foreach-loop">How to modify an array&#39;s values by a foreach loop?</a>  </p>
  </blockquote>
  
  
  
  <p>Why doesn't this work?</p>
  
  <pre><code>$user_list_array = array(
      1 =&gt; array( "first_name" =&gt; "Jim" ),
      2 =&gt; array( "first_name" =&gt; "Bob" )
  )
  
  foreach ($user_list_array as $item ) {
      echo $item["first_name"];
      $item["last_name"] = "test";
  } 
  
  var_dump($user_list_array );
  </code></pre>
  
  <p>I can get the "first_name"s back, but can't add the "last_name";</p>