arrays - PHP to store all variables from loop to use them later -
i trying use wsdl webservice work each parameters. working absolutely fine; however, once script executed, have "log" emailed me.
all works fine when use print
, or echo
inside loop (this display values of different variables loop). however, outside of loop, display 1 variable.
is there way store variables array inside of loop can used later on, outside of loop, example emailing this?
this have tried:
<?php // api request , response $requestparams = array( 'request' => 'hello' ); $client = new soapclient('https://example.com/webservice.asmx?wsdl'); $response = $client->command($requestparams); //load response xml $xml = simplexml_load_string($response); $rows = $xml->children('rs', true)->data->children('z', true)->row; foreach ($rows $row) { $attributes = $row->attributes(); /* xml document contains 2 columns, first attribute to, second attribute ref. extract required data */ $to = (string) $attributes->to; $ref= (string) $attributes->ref; // here few more lines in code other work each variable // works absolutely fine until line /* liket store variables can use them email them log in 1 email */ $tolog .= "<br>$to</br>"; $reflog .="<br>$ref</br>"; } $to = "nobody@example.com"; $subject = "script 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); ?>
i think u need define both variable before starting loop, $tolog = ""; $reflog = ""; if can put whatever in variable in side loop after loop, not need take array.
do not need take array.
Comments
Post a Comment