I am querying my DB, looping through the results and then converting to JSON. I am also using array_unique function.
The problem is my JSON file includes the indexes, how can I return in JSON format without the indexes? I need it this way as I am then planning to feed the JSON array directly into an apexcharts.js chart.
Here is my code:
$month = [];
$value = [];
foreach($rows as $row) {
$month[] = $row['Source'];
$value[] = $row['Days_To_Report'];
}
$month1 = array_unique($month);
$month_json = json_encode($month1, JSON_PRETTY_PRINT);
$fp = fopen('value.json', 'w');
fwrite($fp, $month_json);
fclose($fp);
And here is the JSON output:
{
"0": "CGI Insurance",
"4": "THIRD PARTY CAPTURE - CGI"
}
What I need is this:
{
"CGI Insurance",
"THIRD PARTY CAPTURE - CGI"
}
How can I do this? Thanks