title: PHP Database Results > Array > JSON (without deprecated mysql_fetch_assoc)
body: <p>I've been searching everywhere for a definitive answer to what seems to be a really simple task - unfortunately all the solutions I can find (and there are a lot) use mysql_fetch_assoc which is deprecated.</p>
  
  <p>All I'm trying to do is to take a two column set of results from a database and echo in JSON format - I've managed everything fine except for one bit - I can't work how to get the values in to a two dimensional array (two column array) using array_push.  I just end up with my two column values merged in to one array.  Here's a stripped version of what I've done:</p>
  
  <pre><code>header('Content-Type: application/json');
  $mostPopularStm = $sparklyGenericPdoObj-&gt;prepare("SELECT views, thing FROM X");
  $mostPopularStm-&gt;execute();
  $mostPopularRS = $mostPopularStm-&gt;fetchAll();
  echo '{data:';
  $mostPopularJson = array();
  foreach ($mostPopularRS as $mostPopularItem)
  {
  array_push($mostPopularJson, $mostPopularItem["views"], $mostPopularItem["thing"]);
  }
  echo json_encode($mostPopularJson);
  echo '}';
  </code></pre>
  
  <p>This is producing output like this:</p>
  
  <pre><code>{data:["Monkeyface","43","Giblets","25","Svelte","22","Biriani","21","Mandibles","20"]}
  </code></pre>
  
  <p>But what I need is this:</p>
  
  <pre><code>{data:["Monkeyface":"43","Giblets":"25","Svelte":"22","Biriani":"21","Mandibles":"20"]}
  </code></pre>
  
  <p>I know I can create something manually to do this, using json_encode to format the string on each loop but it seems inefficient.</p>
  
  <p>Any pointers would be hugely appreciated!</p>