PHP query to database return in array format
<p>Let's say I query my database and I get the following result</p>

<pre><code>+---+---+-------+
| N | M | score |
+---+---+-------+
| 0 | 2 |    14 |
| 1 | 0 |    22 |
+---+---+-------+
</code></pre>

<p>After doing <code>$res = $db-&gt;query($query);</code> Is there anyway to store this information in an array. For example, I've tried doing this</p>

<pre><code>      $array = array();    
      while ($row = mysql_fetch_array($res, MYSQL_NUM)) {
            array_push($array, array($row[0], $row[1], $row[2]));
      }
</code></pre>

<p>Because I have this idea that everytime it fetches a row into a numeric array, </p>

<p><code>$row[0] = 0 , $row[1] = 2, $row[2] = 14</code> for the first row and</p>

<p><code>$row[0] = 1, $row[1] = 0, $row[2] = 22</code> for the second row</p>

<p>Please do correct me if I'm wrong because I'm pretty sure I'm wrong :O</p>

<p>EDIT: Reason why I'm asking what $row contains is because I would like to store each row into an array to form a multi dimensional array. For example, <code>{"E":[[0,1,86],[1,0,96]]}</code> after <code>json_encode</code>. So in order to do that, I need to push each row as an array into another array i.e. push the first row as array <code>[0,1,86]</code> into <code>$array</code> followed by pushing the second row as array <code>[1,0,96]</code>. I doubt I can achieve this by doing an associative array. once again correct me if I'm wrong.</p>