I am trying to use some WSDL webservice to do some work with each parameters. This is working absolutely fine; however, once the script is executed, I would like to have "log" emailed to me.
All works fine when I use PRINT, or ECHO inside the loop (this will display all values of different variables from the loop). However, outside of the loop, this will only display ONE variable.
Is there a way to store all variables into array inside of loop so this can be used later on, outside of loop, for example emailing this?
This is what I have tried:
<?php
// API request and response
$requestParams = array(
'Request' => 'Hello'
);
$client = new SoapClient('https://example.com/webservice.asmx?WSDL');
$response = $client->Command($requestParams);
//Load response as XML
$xml = simplexml_load_string($response);
$rows = $xml->children('rs', TRUE)->data->children('z', TRUE)->row;
foreach ($rows as $row) {
$attributes = $row->attributes();
/* XML document contains two columns, first with attribute TO,
second with attribute Ref. This will extract required data */
$To = (string) $attributes->To;
$Ref= (string) $attributes->Ref;
// Here are few more lines in code to do some other work with each variable
// All works absolutely fine until this line
/* I would liket to store all variables so I can use them to email
them as a log in one email */
$ToLog .= "<br>$To</br>";
$RefLog .="<br>$Ref</br>";
}
$to = "[email protected]";
$subject = "Script successfully executed";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = $ToLog . $RefLog
mail($to, $subject, $message, $headers);
?>