title: PHP - Value for each
body: <p>Hello I got a question: I want to make a table of these two arrays. In the first column I want the players name, second column the score and the third column the average of the score. I only get the players in the table and it is repeating itself. I dont know how to make it work. I know the value in the foreach is the players so I knew it would repeat itself but how can I fix this?</p>
  
  <pre><code>&lt;?php
      $aScore = array (1 =&gt; 0, 2 =&gt; 20, 3 =&gt; 4, 4 =&gt; 23, 5 =&gt; 5, 6 =&gt; 4);
  
      $aPlayers = array (1 =&gt; 'Jansen', 2 =&gt; 'Boularus', 3 =&gt; 'Rintintin', 4 =&gt; 'Chavez', 5 =&gt; 'Zomers', 6 =&gt; 'Tahamata');
  
      echo '&lt;table border="1"&gt;';
      echo '&lt;tr&gt;&lt;td&gt;Player&lt;/td&gt;&lt;td&gt;Score&lt;/td&gt;&lt;td&gt;Average score&lt;/td&gt;&lt;/tr&gt;';
  
      foreach($aPlayer as $key =&gt; $value)
      {
          echo '&lt;tr&gt;&lt;td&gt;'.$value.'&lt;/td&gt;&lt;td&gt;'.$value.'&lt;/td&gt;&lt;td&gt;'.$value.'&lt;/td&gt;&lt;/tr&gt;';
      };
  
      echo '&lt;/table&gt;';
  
  
      ?&gt;
  </code></pre>