Creating an array from a database and other data

Can someone help me with this problem PLEASE.

I am trying to create an array from the following:
$dataPointData = “shortQuestion=>’”.$row[shortQuestion]."’,rating=>".$row[rating].",color=>’#".$col."’";
$dataPoint = array($dataPointData);

I would like to get:
array(shortQuestion=>‘Ten points’, rating=>9.0000, color=>’#19e500’)

But am getting (using var_dump to display):
array(1) { [ 0 ]=> string(65) “‘shortQuestion’=>‘Ten points’,‘rating’=>9.0000,‘color’=>’#19e500’” }
i.e. it is seeing $dataPointData as one text entry into the array.

Post your code so we can help.

[php]
$dataPointData = “shortQuestion=>’”.$row[shortQuestion]."’,rating=>".$row[rating].",color=>’#".$col."’";
$exp = explode(’,’, $dataPointData);
$dataPointData = array();
foreach($exp as $e)
{
$new_exp = explode(’=>’, $e);
$dataPointData[$new_exp[0]] = $new_exp[1];
}
print_r($dataPointData);
[/php]

Thank you fastsol :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service