php - 显示来自数据库的 json
问题描述
我正在使用显示测验的 json 结构,但现在我不明白如何正确显示它请帮助我,我想从数据库中读取信息并显示在下面的 json 结构中,谢谢
[
{
"question_id" : 0,
"question": "What is the original native name of Mount Rainier?",
"answers": [
{"id": 0, "text": "Tahoma"},
{"id": 1, "text": "Shuksan"},
{"id": 2, "text": "Stillaguamish"}
],
"correct": 0
},
{
"question_id" : 1,
"question" : "Which image shows a close-up of the Nisqually Glacier?",
"answers" : [
{"id" : 0, "image" : "images/quizImages/glacier_01.jpg" },
{"id" : 1, "image" : "images/quizImages/glacier_02.jpg" },
{"id" : 2, "image" : "images/quizImages/glacier_03.jpg" },
{"id" : 3, "image" : "images/quizImages/glacier_04.jpg" }
],
"correct" : 3
}
]
解决方案
从数据库中获取您的数据并
multidimensional array
使用正在获取数据库的数据。申请
json_encode
决赛array
推荐阅读
- python - Poetry install --no-dev 需要安装 Rust 吗?
- java - 有没有办法将coinbase与java集成?
- node.js - 使用 npm start 在 ios 模拟器上运行 react-native 应用程序时出错 - 无法读取未定义的属性“解析器”
- vb.net - 什么是 Office.Tools.Ribbon.RibbonControlImpl?
- asp.net - 登录会话没有被取消
- c++ - gtkmm.h 无法打开源文件(但编译时使用 pkg-config 标志)
- react-redux - 反应钩子,用 reduxForm 验证表单
- python - 解决 Code jam 2020 中的“嵌套深度”问题?
- node.js - ExpressJS - 返回未定义的函数
- c - 带有空 void main() 的程序的退出代码是什么意思?