[Solved] how to append multiple values to an associative array? [closed]


Seem you need to do something like this,

$values = array();
while($row = mysql_fetch_array($result))
{
  $values[$row['MONTHNAME(dt)']] = $row['SUM(dist)'];
}
print_r($values);

If you need an associative array than do like.

$values[] = array($row['MONTHNAME(dt)'] => $row['SUM(dist)']);

Note: Please, don’t use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLithis article will help you decide which. If you choose PDO, here is a good tutorial.

4

solved how to append multiple values to an associative array? [closed]