【发布时间】:2022-01-20 23:27:51
【问题描述】:
php数组的内容是这样的:
$phpArray =
[
"title" => "The Basics - Networking",
"description" => "Your app fetched this from a remote endpoint!",
"movies" =>
[
[
"id" => $id,
"title" => $title,
"releaseYear" => $releaseYear
]
]
];
}
echo json_encode(array_values($phpArray));
返回:
[
"The Basics - Networking",
"Your app fetched this from a remote endpoint!",
[
{
id: "1",
title: "Star Wars",
releaseYear: "1977"
}
]
]
但为了让它工作,它应该显示:
{
title: "The Basics - Networking",
description: "Your app fetched this from a remote endpoint!",
movies: [
{
id: "1",
title: "Star Wars",
releaseYear: "1977"
}
]
}
问题是我如何渲染数据和数组以获得正确的结果(即上面介绍的后一个数组)。
任何有用的提示将不胜感激! :-)
【问题讨论】:
-
删除
array_values,你应该会很好。 -
谢谢!在看到你的答案之前,我意识到了这一点。 :-) 感谢您的反馈!
标签: php json react-native