Solr 以以下 JSON 格式返回响应。
{
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"indent":"on",
"start":"0",
"q":"*:*",
"wt":"json",
"version":"2.2",
"rows":"10"}},
"response":{"numFound":3,"start":0,"docs":[
{
"student_id":"AB1001",
"student_name":[
"John"]
},
{
"student_id":"AB1002",
"student_name":[
"Joe"]
},
{
"student_id":"AB1003",
"student_name":[
"Lorem"]
}]
}}
使用PHP读取student_id、student_name的简单方法是什么?
Use $obj = json_decode($yourJSONString);
将其转换为对象。
然后使用foreach($obj->response->docs as $doc)
迭代“文档”。
然后您可以使用访问这些字段$doc->student_id
and $doc->student_name[0]
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)