title: Populating dynamically-created arrays in PHP
body: <p>I'm building a web-app that has a rather large (10K rows) reference table.</p>
  
  <p>Table reference has a category, id , description.</p>
  
  <p>As I'm using this reference a data a lot to fill drop-down boxes and such, I'm trying to put them in arrays. I had them in one large array it first, but it seems to me it's more efficient to have an array per category within the reference table.</p>
  
  <p>The dynamic variable names are created, but populating them from another array is not working.</p>
  
  <pre><code>$r_refcats = mysqli_query($global_dbh,"select distinct(cat) from reference");
  while(($row = mysqli_fetch_array($r_refcats)) != false){ $$row[0]=array();};
  
  $r_references = mysqli_query($global_dbh,"select cat,id,description from reference");
  while(($row = mysqli_fetch_array($r_references)) != false) { $$row[0]=array($row);}
  </code></pre>
  
  <p>Because I can't use a <code>$$row[0][]</code> in the last line, it keeps overwriting the same value :)</p>
  
  <p>Any tips on how to do this correctly?</p>