Read JSON Data Using PHP

前端 未结 5 1127
暗喜
暗喜 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:23

    $json_a = json_decode($string, TRUE);
    $json_o = json_decode($string);
    
    
    #array method
    foreach($json_a['response']['docs'] as $students)
    {
        echo $students['student_id']." name is ".$students['student_name'][0];
        echo "
    "; } #Object Method`enter code here` foreach($json_o->response->docs as $sthudent_o) { echo $sthudent_o->student_id. " name is ".$sthudent_o->student_name[0]; echo "
    "; }

提交回复
热议问题