Reputation: 65
Currently, I have a JSON encoded array that looks like this:
[
{
"username1": {
"post": {
"some_key" : "some_value"
}
}
},
{
"username1": {
"post": {
"some_key" : "some_value"
}
}
}
]
But how can I make it so that the json follows this pattern:
username -> array_of_posts -> post -> values
instead of the current pattern?
Thanks
Here is my current code:
while ($row = mysql_fetch_assoc($query)) {
$row['username'] = $username;
$returns[][$username]["post"] = $row;
}
}
echo json_encode(array_values($returns));
Upvotes: 1
Views: 376