title: php: how to update a value in associative array by key
body: <p>I'm having a hard time trying to update the values in my array. I made a simple example to illustrate this: the array contains names of players and the amount of points they have. After each round I want to update their points like this: </p>
  
  <p>(which is not working)</p>
  
  <pre><code> $players = array (
     array (
     "id"        =&gt; 0, 
     "name"      =&gt; "John",
     "points"    =&gt; 0
     ),
  
     array (
     "id"        =&gt; 1, 
     "name"      =&gt; "Chris",
     "points"    =&gt; 0
     ),
  
     array (
     "id"        =&gt; 2, 
     "name"      =&gt; "Peter",
     "points"    =&gt; 0
     ),
  
     array (
     "id"        =&gt; 3, 
     "name"      =&gt; "Greg",
     "points"    =&gt; 0
     ),
  
   );
  
  
   $points0 = 10;
   $points1 = 20;
   $points2 = 30;
   $points3 = 40;
  
  
   $i = 0;
   foreach ($players as $player) {
          if ($player["id"] == $i) { 
           $player["points"] = ${"points".$i}; 
       }    $i++;
   }
  
   var_dump($players);
  </code></pre>
  
  <p>Must be something stupid, but I've been trying for hours and I just can't find it.</p>
  
  <p>Thanks for the help!</p>