title: Send mail with values from returned SOAP request which is converted to json
body: <p>I have a form that I am submitting via PHP cURL as SOAP to a WSDL. It submits fine, and my PHP handler takes the returned xml and converts it to a json string like this:</p>
  
  <pre><code>$soap_do = curl_init();
  curl_setopt($soap_do, CURLOPT_URL, $url2 );
  curl_setopt($soap_do, CURLOPT_HEADER, false);
  curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 100);
  curl_setopt($soap_do, CURLOPT_TIMEOUT,        100);
  curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
  curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($soap_do, CURLOPT_POST,           true );
  curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $xml_post_string);
  curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $headers);
  
  $result = curl_exec($soap_do);
  if ($result === false) {
      $err = 'Curl error: ' . curl_errno($soap_do);
      print $err;
  } else {
      $xml = simplexml_load_string($result);
      $body = $xml-&gt;xpath("//soapenv:Body//demosetupReturn")[0];
      $output = [];
      foreach ( $body as $item)  {
          $output[(string)$item-&gt;key] = (string)$item-&gt;value;
      }
      echo json_encode($output);
  }
  curl_close($soap_do);
  </code></pre>
  
  <p>The returned data (xml/SOAP) is converted to a json string which looks like this:</p>
  
  <pre><code>{"DemoUName":"FBar308r","DemoPass":"Demo5538r","FutAcct":"DEMO06341r","FxAcct":"","UUID":"ED31DA3C-D015-4B7F-AAB2-0B6ECBF17FEr","Result":"User has been added with ID = 57218r Account DEMO06341r2 has been moved from User Pool to User FBar308r "}
  </code></pre>
  
  <p>I need to access the $output, and extract some values, say "DemoUName", "DemoPass" etc from it and stuff that into a php sendmail function. How do I access the json data items as PHP $var and send mail?</p>