我有一个多维数组,如下所示:
Array
(
[0] => Array
(
[0] => Array
(
[id] => 3
)
[1] => Array
(
[id] => 1
)
[2] => Array
(
[id] => 2
)
[3] => Array
(
[id] => 5
)
[4] => Array
(
[id] => 4
)
)
[1] => Array
(
[0] => Array
(
[id] => 1
)
[1] => Array
(
[id] => 3
)
[2] => Array
(
[id] => 4
)
[3] => Array
( …
Run Code Online (Sandbox Code Playgroud) 我有两个网络服务:
一个人返回"文章",如下所示:
[
{
"id": "1",
"headline": "some text",
"body": "some text",
"authorId": "2"
},
{
"id": "2",
"headline": "some text",
"body": "some text",
"authorId": "1"
}
]
Run Code Online (Sandbox Code Playgroud)
另一个返回像这样的"作者",给出一个id:
{
"id": "1",
"name": "Test Name",
"email": "test@test.com",
"photo": "path/to/img"
}
Run Code Online (Sandbox Code Playgroud)
我想将两者结合起来,这样我就可以在文章概览列表中显示作者姓名和照片.
像这样:
[
{
"id": "1",
"headline": "some text",
"body": "some text",
"authorId": "2",
"author_info": {
"id": "2",
"name": "Another Test Name",
"email": "test2@test.com",
"photo": "path/to/img"
}
},
{
"id": "2",
"headline": "some text",
"body": "some text",
"authorId": "1"
"author_info": …
Run Code Online (Sandbox Code Playgroud)