Read JSON Data Using PHP

前端 未结 5 1119
暗喜
暗喜 2020-11-30 10:41

Solr returns response in following JSON format.

{
  \"responseHeader\":{
    \"status\":0,
    \"QTime\":2,
    \"params\":{
      \"indent\":\"on\",
      \         


        
5条回答
  •  鱼传尺愫
    2020-11-30 11:11

    PHP has a json_decode function that will allow you to turn a JSON string into an array:

    $array = json_decode($json_string, true);
    $student_id = $array['response']['docs'][0]['student_id'];
    ...
    

    Of course, you might want to iterate through the list of students instead of accessing index 0.

提交回复
热议问题