I'm trying to create Highcharts chart from mysql, I have code like this:
xAxis: {
categories: [<?php echo implode($column, ','); ?>]
}
and column has been grabbed from mysql:
$column = array();
$column[] = $row['blabla'];
What I am actually getting is:
xAxis: {
categories: [data1,data2,data3,data4,data5]
}
but it has to be like this:
xAxis: {
categories: ["data1","data2","data3","data4","data5"]
}
How can I format it like that?
json_encode
will format your array of strings as a JSON object, including escaping, etc., which can then be passed into HighCharts with the following:Just input the data with the quotes.
$column[] = '"'.$row['blabla'].'"';
this will work too.