SOAP PHP and Arrays

Associate
Joined
13 Nov 2003
Posts
1,567
Location
Manchester
Hi All

Got a slight issue with some code I am trying to work out.

I need to use SOAP to retrieve some records and insert them into an array

Below is the code
Code:
<?php

	$client = new SoapClient("******/Service.asmx?wsdl");
	
	$contact_sources = array($client->GetContactSource(''));
	
	
	print_r($contact_sources);
	
	
	foreach ($contact_sources as $value) {
	echo $value;
	
	}
	
?>

However it doesn't seem to work.

A print_r on the array displays the following.

Code:
Array ( [0] => stdClass Object ( [GetContactSourceResult] => stdClass Object ( [string] => Array ( [0] => Ambient Media [1] => Direct Mail [2] => Magazine Adverts [3] => Spanish Press [4] => Website ) ) ) )

which says to me that I have got something with the query assignment wrong, but I am not too hot on this and am not sure how to fix it.

Any help would be appreciated

Thanks
Aaron
 
It has returned an object inside an array.

I haven't used any of the SOAP functions but you could get at the inner object with:
PHP:
$contactSources = $contact_sources[0];

* edit * was being dozy.
 
Last edited:
Back
Top Bottom