title: Mysql to JSON, how to get a nested array?
body: <p>I'm trying to get a JSON-file looking like this:</p>
  
  <pre><code>[
      [
      'Disease', [ latitude, longitude, magnitude, latitude, longitude, magnitude, ... ]
      ],
      [
      'Disease', [ latitude, longitude, magnitude, latitude, longitude, magnitude, ... ]
      ]
  ];
  </code></pre>
  
  <p>This is what I've done:</p>
  
  <pre><code>&lt;?php
  
      $sqlDisease = mysql_query("SELECT DISTINCT Disease FROM DiseaseData") or die(mysql_error());
  
      while($rowDisease = mysql_fetch_assoc($sqlDisease)){
  
              $sqlData = mysql_query("
              SELECT lat, lng, magnitude 
              FROM DiseaseData 
              WHERE Disease = '".$rowDisease."'") 
              or die(mysql_error());
  
              while($rowData = mysql_fetch_assoc($sqlData)){
                  $data[] = array_values($rowData);
              }
  
              $result[] =  array_values($rowDisease, $data);
  
      }
  
      $json = json_encode($result);
      $file = 'testRes.json';
      file_put_contents($file, $json);
  </code></pre>
  
  <p>I end up with a JSON-file looking like this: </p>
  
  <pre><code>[null,null,null]
  </code></pre>
  
  <p>The problem probably lies within the nested while-loops or array_values(), but I can't figure out exactly where.</p>