title: parsing the Paypal REST API response
body: <p>I have json_decoded my paypal rest api response and gotten this:</p>
  
  <pre><code>["body"]=&gt; object(stdClass)#4 (8) { 
  
      ["id"]=&gt; string(28) "PAY-66D616332R6551639KJLSMVQ" 
      ["create_time"]=&gt; string(20) "2013-10-10T22:12:38Z" 
      ["update_time"]=&gt; string(20) "2013-10-10T22:12:39Z" 
      ["state"]=&gt; string(7) "created" 
      ["intent"]=&gt; string(4) "sale" 
      ["payer"]=&gt; object(stdClass)#5 (2) { 
          ["payment_method"]=&gt; string(6) "paypal" 
          ["payer_info"]=&gt; object(stdClass)#6 (0) {} 
      } 
      ["transactions"]=&gt; array(1) { 
          [0]=&gt; object(stdClass)#7 (3) { 
              ["amount"]=&gt; object(stdClass)#8 (3) { 
                  ["total"]=&gt; string(6) "500.85" 
                  ["currency"]=&gt; string(3) "USD" 
                  ["details"]=&gt; object(stdClass)#9 (2) { 
                      ["subtotal"]=&gt; string(6) "460.90" 
                      ["shipping"]=&gt; string(5) "39.95" 
                  } 
              } 
              ["description"]=&gt; string(43) "Mike and Maureen Photography - Order ID #10" 
              ["item_list"]=&gt; object(stdClass)#10 (1) { 
                  ["items"]=&gt; array(2) { 
                      [0]=&gt; object(stdClass)#11 (5) { 
                          ["name"]=&gt; string(48) "The Bean-8" x 10" - floating frame - black frame" 
                          ["sku"]=&gt; string(7) "20 - 13" 
                          ["price"]=&gt; string(6) "160.95" 
                          ["currency"]=&gt; string(3) "USD" 
                          ["quantity"]=&gt; string(1) "1" 
                      } 
                      [1]=&gt; object(stdClass)#12 (5) { 
                          ["name"]=&gt; string(62) "40 Steps and a View-36" x 48" - 0.75" thin gallery wrap canvas" 
                          ["sku"]=&gt; string(5) "7 - 6" 
                          ["price"]=&gt; string(6) "299.95" 
                          ["currency"]=&gt; string(3) "USD" 
                          ["quantity"]=&gt; string(1) "1" 
                      } 
                  } 
              } 
          } 
      } 
      ["links"]=&gt; array(3) { 
          [0]=&gt; object(stdClass)#13 (3) { 
              ["href"]=&gt; string(79) "https://api.sandbox.paypal.com/v1/payments/payment/PAY-66D616332R6551639KJLSMVQ" 
              ["rel"]=&gt; string(4) "self" 
              ["method"]=&gt; string(3) "GET" 
          } 
          [1]=&gt; object(stdClass)#14 (3) { 
              ["href"]=&gt; string(94) "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&amp;token=EC-1XB37931V5368954G" 
              ["rel"]=&gt; string(12) "approval_url" 
              ["method"]=&gt; string(8) "REDIRECT" 
          } 
          [2]=&gt; object(stdClass)#15 (3) { 
              ["href"]=&gt; string(87) "https://api.sandbox.paypal.com/v1/payments/payment/PAY-66D616332R6551639KJLSMVQ/execute" 
              ["rel"]=&gt; string(7) "execute" 
              ["method"]=&gt; string(4) "POST" 
          } 
      } 
  } 
  </code></pre>
  
  <p>I am trying to check the value of 'state' but I cant seem to figure out how to reference that value. I have tried: (<code>$result</code> is the variable where the array is located)</p>
  
  <pre><code>$result['body']['state']
  $result['state']
  $body['state']
  </code></pre>
  
  <p>None of those work, so can anyone tell me how to reference the key 'state' in that mess up there? I am usually pretty good with PHP but for some reason I can not figure this one out.</p>
  
  <p>Thanks for your help.</p>
  
  <p><em>Edit</em></p>
  
  <p>I have formatted the response so its easier to ready but I am stuck on selecting the [1] href value. If I base it on the previous example I would use </p>
  
  <p>$result['body']->link but how do I get past that to the specific href in [1]?</p>