I need to access nested items in json response. Here is my json response.
{
"payments": [
{
  "state": "approved",
  "intent": "sale",
  "payer": {
    "payment_method": "paypal",
    "status": "VERIFIED",
    "payer_info": {
      "email": "xxxx.com",,
      "payer_id": "xxxxxx",
      "shipping_address": {
        "line1": "1 xxx St",
        "recipient_name": "test buyer"
      }
    }
  },
  "transactions": [
    {
      "amount": {
        "total": "39.95",
        "currency": "USD",
        "details": {
          "subtotal": "39.95"
        }
      },
      "related_resources": [
        {
          "sale": {
            "id": "xxxxx",
            "create_time": "2016-10-26T08:56:09Z",
            "update_time": "2016-10-26T08:56:09Z",
            "amount": {
              "total": "39.95",
              "currency": "USD"
            },
            "payment_mode": "INSTANT_TRANSFER",
            "state": "completed",
            "transaction_fee": {
              "value": "1.46",
              "currency": "USD"
            },
          }
        }
      ]
    }
  ],
} 
], 
"count": 1
}
I know to access items in json in following way.
$response = json_decode($jsonResponse);
$my = $response->payments;
$new = json_encode($my);
return $my;
I went through several questions like How do I extract data from JSON with PHP? but cannot solve the problem.
I need to access payment_mode in related_resources. How I do this?
 
     
     
    