title: Accessing value of index of array within array
body: <p>I have an array of arrays called $excelData. print_r($excelData) returns the following:
  </p>
  
  <pre class="lang-sql prettyprint-override"><code>Array ( 
  [0] =&gt; Array ( 
                [0] =&gt; Array ( 
                                [0] =&gt; name 
                                [1] =&gt; test 
                                [2] =&gt; 4 
                                [3] =&gt; test@test.com 
                                [4] =&gt; it4249 
                                [5] =&gt; sha256:1000: 
                               ) 
                ) 
  [1] =&gt; Array ( 
                [0] =&gt; Array ( 
                                [0] =&gt; fseconf 
                                [1] =&gt; test2 
                                [2] =&gt; 3 
                                [3] =&gt; example@test.com 
                                [4] =&gt; ft9655 
                                [5] =&gt; sha256:1000: 
                                           ) 
                 ) 
  )
  </code></pre>
  
  <p>and I'm trying to print the 4th index in each case (i.e. it4249 and ft955) with the following code:
  </p>
  
  <pre class="lang-php prettyprint-override"><code>$query = "INSERT INTO tblTest (username, fname, surname, year, email) VALUES";
  $qPart = array_fill(0, count($excelData), "(?, ?, ?, ?, ?)");
  $query .=  implode(",",$qPart);
  $sth = $dbh-&gt;prepare($query);
  $i = 1;
  
  print_r($excelData);
  echo "&lt;br /&gt;";
  echo "&lt;br /&gt;";
  
  Foreach($excelData As $Row){
  
            echo "Username: ".$Row[0][4];
            echo "&lt;br /&gt;";
            echo "&lt;br /&gt;";
            $sth-&gt;bindValue($i++, $Row[0][4]);
            $sth-&gt;bindValue($i++, $Row[0][0]);
            $sth-&gt;bindValue($i++, $Row[0][1]);
            $sth-&gt;bindValue($i++, $Row[0][2]);
            $sth-&gt;bindValue($i++, $Row[0][3]); 
   }
  </code></pre>
  
  <p>But it simply prints it4249 both times. Why does this not work and how do I get this right?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Changing my loop to pass by reference as below solves my problem but I have no idea why - any explanations?</p>
  
  <pre class="lang-php prettyprint-override"><code>Foreach($excelData As &amp;$Row){
  }
  </code></pre>