It is an array, so you can loop over it easily using foreach
:
foreach ($result->GetIncomingMessagesResult->SMSIncomingMessage as $message) {
echo $message->Reference;
}
However it is worth noting that PHP’s SoapClient
by default appears to return arrays as a PHP array only when there is more than one value in the array – if there is only one value you will just get that value (not contained within an array). An easy way around this is to use the option SOAP_SINGLE_ELEMENT_ARRAYS
in the SoapClient
constructor; this will prevent this behaviour and ensure you always get arrays.