I have the following which assigns the values I need to an array in php
$resultsAr[$row['stop_name']][$row['route_long_name']][] = $row['arrival_time'];
However when I convert this to JSON it does not have any keys.
echo json_encode($resultsAr);
e.g.
{
Stop1: {
Destination1: [
"11:13",
"11:25"
],
Destination2: [
"11:15",
"11:27"
],
Destination3: [
"11:14",
"11:23",
"11:26"
]
},
They keys are actually the values. How can I assign key names to the array?
Edited: the required JSON output would be keys with values:
[Stops => all stops] [destinations => destinations] [times => arrival times]