I run the following PHP-code:
$client = new SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
var_dump($client->checkVat(array(
'countryCode' => 'BE',
'vatNumber' => '0861091467'
)));
foreach ($client as $key => $value) {
echo $key . ' = ' . $value . "\n";
}
It procudes the following output on screen:
object(stdClass)#2 (6) {
["countryCode"]=>
string(2) "BE"
["vatNumber"]=>
string(10) "0861091467"
["requestDate"]=>
string(16) "2021-03-10+01:00"
["valid"]=>
bool(true)
["name"]=>
string(8) "BV myKMO"
["address"]=>
string(26) "Kapellebaan 55
2560 Nijlen"
}
_soap_version = 1
sdl = Resource id #2
httpsocket = Resource id #3
_use_proxy = 0
httpurl = Resource id #4
Then how can we store "BV myKMO" in a one-dimensional variable ? I'm looking for something like
$varname = $client->sdl->name;
Thank you,
var_dumpandforeachoutput are totally different and neither shows thesdlproperty.and the following loop...would produce...not from the previous data you showed, it wouldn't. If you're going to use examples that's great, but please at least check that they make sense before posting them :-)echo $myvar->name;should be what you need to in order to refer to the value. It's unclear wheresdlcomes into it. Simple demo: sandbox.onlinephpfunctions.com/code/…$clientdoesn't contain the data. It contains your SOAP client. Your data is contained in the object returned by the call to thecheckVat()function...but you're only feeding that to var_dump, you aren't retaining it for later use. And I still have no idea why you thinksdlis relevant to anything, it's unclear what's in it just from that foreach output. (why you didn'tvar_dump($client)too for your debugging instead of using foreach, I don't understand).$result = $client->checkVat(array( 'countryCode' => 'BE', 'vatNumber' => '0861091467' )); echo $result->name;