title: Adding arrays to multi-dimensional array within loop
body: <p>I am attempting to generate a multi-dimensional array with each sub array representing a row I want to insert into my DB. The reason for this is so I can use CodeIgniters batch_insert function to add each row to the DB.</p>
  
  <p>I am attempting to create each sub array within a loop and insert it into a multidimensional array. Google suggested using array_merge, but after using 'print_r' on the multidimensional array with the code below, only the last sub-array is being displayed.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>$allplayerdata = array(); //M-D container array
  for ($i = 1; $i &lt;= 11; $i++)
  {
      $playerdata = array(
                          'player_id' =&gt; $this-&gt;input-&gt;post('player' . $i),
                          'goals' =&gt; $this-&gt;input-&gt;post('playergoals' . $i),
                          'player_num' =&gt; $i,
                          'fixture_id' =&gt; $this-&gt;input-&gt;post('fixture_id')
                      );
  
      //Merge each player row into same array to allow for batch insert
      $allplayerdata = array_merge($allplayerdata, $playerdata);
  }
  print_r($allplayerdata);
  </code></pre>
  
  <p>Can anyone spot where I'm going wrong? Help is appreciated!</p>