title: Access array inside JSON element using PHP
body: <p>How do I access an array nested inside a JSON element with PHP.  Here is the code I'm using (simplified for the example), I can access <code>from_email, html, subject</code> etc. easily, but how would I access the <code>to</code> email address <code>recipient@addresshere.co.uk</code>? Do I need some sort of <code>foreach</code> loop, on the basis that there could be more than one entry?</p>
  
  <p>JSON</p>
  
  <pre><code>{
      "event": "inbound", 
      "msg": {
          "dkim": {}, 
          "email": "myemail@addresshere.co.uk", 
          "from_email": "example.sender@mandrillapp.com", 
          "headers": {}, 
          "html": "This is an example inbound message.", 
          "raw_msg": "Received: from mail115.us4.mandrillapp.com", 
          "sender": null, 
          "spam_report": {}, 
          "spf": {}, 
          "subject": "This is an example webhook message", 
          "tags": [ ], 
          "template": null, 
          "text": "This is an example inbound message.", 
          "text_flowed": false, 
          "to": [
              [
                  "recipient@addresshere.co.uk", 
                  null
              ]
          ]
      }
  }
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>$emailp = urldecode($_REQUEST['mandrill_events']); // The above JSON
  $email = array_pop(json_decode($emailp));
  
  $from_email = $email-&gt;msg-&gt;from_email; // From email
  $html = $email-&gt;msg-&gt;html; // HTML Message
  $subject = $email-&gt;msg-&gt;subject; // Subject
  $to = ????
  </code></pre>
  
  <p>Thanks</p>