Trying to add array keys without array values
<p>Ok, so I'm trying to write something which will analyze the US Presidential candidates.</p>

<p>I'm trying to add all of the values up on a given day - I'm part of the way through that.</p>

<p>Anyway, $romlinearray - I want to have two values inside, the date, and the value for a given day. I want to insert them inside the <code>if ($romneydiff == 0) {</code> block.</p>

<p>What I am having a problem with is generating an array with a key name (i.e. I want to be able to do $romlinearray["value"]) and have it pull a value, but the value isn't going to be inserted until later.</p>

<p>How can I create an array with a key, but without a value as of yet?</p>

<pre><code>$resultromney = mysql_query("SELECT category, value, timestamp from results where name='".$chartname2."'");
if (!$resultromney) {
    die('Invalid query, please contact administrator');
}

$posromney = 0;
$negromney = 0;
$dateromney = "1/1/2012";
$romray = array();

while ($twitromney = mysql_fetch_assoc($resultromney)) 
{

$romneytime = intval($twitromney["timestamp"]);
$romneydate = date('m/d/Y', $romneytime);
$romlinearray = array(); // THIS IS WHERE THE PROBLEM IS
$romneydiff = date_diff($dateromney, $romneytime);

$PLromney = 0;
$NLromney = 0;
$totalromney = 0;

if ($romneydiff == 0) {


switch ($twitromney["category"]) {
    case "composed":
        $PLromney = $PLromney + $twitromney["value"];
break;
    case "elated":
        $PLromney = $PLromney + $twitromney["value"];
break;
    case "clearheaded":
        $PLromney = $PLromney + $twitromney["value"];
break;
    case "agreeable":
        $PLromney = $PLromney + $twitromney["value"];
break;
    case "energetic":
        $PLromney = $PLromney + $twitromney["value"];
break;
    case "unsure":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "tired":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "depressed":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "guilty":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "confused":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "anxious":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "hostile":
        $NLromney = $NLromney + $twitromney["value"];
break;
    case "confident":
        $PLromney = $PLromney + $twitromney["value"];
break;
}
$totalromney = $PLromney - $NLromney;

$romlinearray["value"] = $totalromney + $romlinearray["value"];
}
</code></pre>
