title: add key=>value pair to associative array in php While loop
body: <p>I create a simple associative array in a WHILE loop. The key is the field name and the value is a Unix timestamp. I would like to add to this array a new key=>value pair 'Date"=>format the Unix timestamp, json_encode the array and return it to a JQ script in an Ajax call. The array looks like this:</p>
  
  <pre><code>Array 
    ( [0] =&gt; Array 
      ( [Post_timestamp] =&gt; 1370876787 ) [Date] =&gt; 2013 06 10 ) 
  </code></pre>
  
  <p>However, shouldn't it look like this:</p>
  
  <pre><code>Array 
    ( [0] =&gt; Array ( [Post_timestamp] =&gt; 1370876787 [Date] =&gt; 2013 06 10))
  </code></pre>
  
  <p>I guess my question is "how do I create the array so that the formatted timestamp and the raw timestamp are a single record"? Right now, it appears as if they are two records.</p>
  
  <p>PHP</p>
  
  <pre class="lang-php prettyprint-override"><code>$query = "SELECT Post_timestamp FROM Comments LIMIT 1";
  $result = mysqli_query($dbc, $query);
  
  while ($rows = mysqli_fetch_assoc($result)) {
      $array[] = $rows;
      $array['Date'] = date("Y m d", $rows['Post_timestamp']);
  }
  </code></pre>