-1
こんにちは、私はこれをどうやって達成できるのかちょっと混乱しています。これは私のjsonレスポンスがどのように見えるかです:json配列をPHPのjsonオブジェクトの中に入れてください。
some_array: [
{
some_json_object_atribute_1:
some_json_object_atribute_2:
// Here i need an array
json_array: [
]
}
{
some_json_object_atribute_1:
some_json_object_atribute_2:
}
]
しかし、私はjson配列から1行しか得ません。これは、コードの一部です:
$response["chat_rooms"] = array();
while ($chat_room = $result->fetch_assoc()) {
$tmp = array();
$tmp["chat_room_id"] = $chat_room["chat_room_id"];
$unread_messages = $db->getAllUnreadMsgsFromChatRoom($user_id, $chat_room["chat_room_id"]);
while ($unread_message = $unread_messages->fetch_assoc()) {
// Here i need one json array
$tmp["message_id"] = $unread_message["message_id"];
}
array_push($response["chat_rooms"], $tmp);
}
'$ TMP [ "MESSAGE_ID"] [] = $ unread_message [ "MESSAGE_ID"];'動的に新しいアイテムを追加します。 – AbraCadaver