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:
Array
( [0] => Array
( [Post_timestamp] => 1370876787 ) [Date] => 2013 06 10 )
However, shouldn't it look like this:
Array
( [0] => Array ( [Post_timestamp] => 1370876787 [Date] => 2013 06 10))
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.
PHP
$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']);
}