At 21:04 08/06/2005 +0000, you wrote:
To: <php-db@lists.php.net>
MIME-Version: 1.0
Message-ID: <[EMAIL PROTECTED]>
From: [EMAIL PROTECTED]
Date: Wed, 8 Jun 2005 16:04:33 -0500
Content-Type: multipart/alternative; boundary="=_alternative 0073C60C8625701A_="
Subject: Creating an Associative Array

This question will probably be off-topic for some, but it does relate to a
database application so please bear with me.

I'm pulling date-times out of a MySQL db:

mysql> select date_format(`date_time`, '%Y.%m.%d %H:%i:%s') as rightNow
from location1 order by date_time desc limit 1;

+----------------------------+
| rightNow                     |
+----------------------------+
| 2005.06.08 14:24:11 |
+----------------------------+

This code snippet is producing an array of arrays rather than a simple
associative array:

<?php

$now = time();
//$dateArray = array(); (output is the same with or without this line)

for($counter = 0; $counter <= 3600; $counter++)
{
      $dateArray[] = array(date("Y.m.d H:i:s", $now - $counter) =>
(int)ceil(980 - ($counter * .2333333333333)));
}

Actually you meant to pass the $dateArray an index - as you didn't, PHP helpfully created sequential numeric indices.
Try this instead, providing the date index string yourself :

$dateArray[ date("Y.m.d H:i:s", $now - $counter) ] = array( (int)ceil(980 - ($counter * .2333333333333)));


Cheers - Neil


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to