title: MailGun API doesn't output JSON
body: <p>I am trying to test sending emails using the Mailgun api. I am using PHP to interface with the api. Following is the code that I have tried (from <a href="http://documentation.mailgun.com/api-sending.html#examples" rel="nofollow">here</a>).  </p>
  
  <pre><code># Include the Autoloader (see "Libraries" for install instructions)
  require 'vendor/autoload.php';
  use Mailgun\Mailgun;
  
  # Instantiate the client.
  $mgClient = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
  $domain = "samples.mailgun.org";
  
  # Make the call to the client.
  $result = $mgClient-&gt;sendMessage("$domain",
                array('from'    =&gt; 'Excited User &lt;me@samples.mailgun.org&gt;',
                      'to'      =&gt; 'Baz &lt;baz@example.com&gt;',
                      'subject' =&gt; 'Hello',
                      'text'    =&gt; 'Testing some Mailgun awesomness!'));
  var_dump($result); 
  </code></pre>
  
  <p>Now when I try the API, I get a response similar to the following: </p>
  
  <pre><code>stdClass Object ( [http_response_body] =&gt; stdClass Object ( [message] =&gt; Queued. 
  Thank you. [id] =&gt; &lt;12345678901234.1234.12345@samples.mailgun.org&gt; )
  [http_response_code] =&gt; 200 )
  </code></pre>
  
  <p>How do I assign this output to an array or convert this to simple JSON using PHP? Is there some in-built PHP function which would format the above output to simple JSON or do I need to do something else. I have beginner level PHP skills. </p>
  
  <p>Any help would be very appreciated. Thanks!</p>
  
  <p>P.S.: The mailgun api key used above is from the MailGun API documentation.</p>
  
  <p><strong>UPDATE:</strong> Thanks guys. I got it working. </p>
  
  <pre><code>$darr=json_encode($result);
  $data=  json_decode($darr,true);
  
  # Prints out the individual elements of the array
  echo $data["http_response_body"]["message"]."&lt;br&gt;";
  echo $data["http_response_body"]["id"]."&lt;br&gt;";
  echo $data["http_response_code"];
  </code></pre>