I've made a script to track visitors on my website and now I want to display the amount of visitors per day in a Google Line Chart with JSON.
This is some PHP code I wrote to display the date and amount of visitors for that day in an array:
$dateQuery = $db->prepare("SELECT date FROM tracked");
$dateQuery->execute();
$rows = $dateQuery->fetchAll(PDO::FETCH_ASSOC);
$array = array();
foreach ( $rows as $row ) {
$day = explode(' ', $row['date']);
if ( !key_exists($day[0], $array) ) {
$array[$day[0]] = 0;
}
$array[$day[0]] += 1;
}
This is the output when I print_r the array:

Now for this output to work in the Google Charts API I need the JSON format to be like this:
[["2016-02-18",6],["2016-02-17",5]]
Instead I get this with json_encode($array):
{"2016-02-17":5,"2016-02-18":6}
I have a basic understanding now of arrays and loops but I can't seem to think of a solution to solve my problem.