JSON Encode Help
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 jso开发者_开发技巧n 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));
$returns[$username][] = $row;
echo json_encode($returns);
精彩评论