title: PHP fetch MySQL array with an index
body: <p>When fetching an array from MySQL the rows are typically returned with a key from 0 to the size of your recordset:</p>
  
  <pre><code>row[0][key][value]
  </code></pre>
  
  <p>Is it possible to have one of the fields from the select statement returned as the key in the array?</p>
  
  <p>For example.  Assuming my data set has StudentID, Name, City, etc.</p>
  
  <p>How can I select into an array where I could refer to the StudentID as the index like this:</p>
  
  <pre><code>rows[StudentID][Name]
  rows[StudentID][City]
  etc.
  </code></pre>
  
  <p>Thanks!</p>