PHP Multi level JSON Pull/Retrieve [duplicate] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, June 17, 2022

PHP Multi level JSON Pull/Retrieve [duplicate]

I am having a little trouble grabbing data from JSON code. I am trying to grab "Message" value under "innererror" from the json code which is "entity : An error has occurred."

$json = '{
  "odata.error":{
        "code":"",
        "message":{
            "lang":"en-US",
            "value":"The request is invalid."
            },
        "innererror":{
            "message":"entity : An error has occurred.",
            "type":"",
            "stacktrace":""
            }
  }
}';
$json_data = json_decode($json,true);

$main_response_data = $json_data['innererror'];


echo $main_response_data[0]['message'];



source https://stackoverflow.com/questions/72650383/php-multi-level-json-pull-retrieve

No comments:

Post a Comment