Extract Result Key

0

I have this function .......

$client = new SoapClient('http://wss........N.asmx?wsdl');
$funcao = 'ConsultarUsuario';
$argumentos = array($funcao => array(
    'ChaveUsuario' => 'U10..........921',
    'aplicativo' => 'S..........ob',
    'RotaDatabase' => 'C:\Ine......................s\database.mdb'
    ));
$resultado = $client->__soapCall($funcao, $argumentos);
echo ' RESPOSTA = ';
print_r($resultado);

My response in the browser

RESPOSTA = stdClass Object ( [ConsultarUsuarioResult] => stdClass Object ( [string] => Array ( [0] => Usuário Registrado [1] => User Teste Mob1 [2] => U10SEG0721 [3] => 10/07/2017 03:00:00 [4] => 10/08/2017 03:00:00 [5] => Ativo [6] => Paulo R Maia [7] => 55555555555555 [8] => endereço teste [9] => 77 [10] => casa [11] => bairro teste [12] => cidade teste [13] => sp [14] => 55555555 [15] => 55555555555 [16] => [email protected] [17] => Sistema [18] => 99 [19] => Testando [20] => 1 ) ) )

I need to extract values from some of these keys and store them in $ variables

I'm trying like this, but with no success.

But my problem is that I can not extract the values of the keys to store in variables

Attempts .......

$resultado->ConsultarUsuarioResult[6];
echo $resultado;

Not Yet .........

$valorExtraido = $resultado->ConsultarUsuarioResult[6];
echo $valorExtraido;

. . . What would be the solution?

    
asked by anonymous 01.08.2017 / 05:57

1 answer

1

The correct way to use it would be:

$resultado->ConsultarUsuarioResult->string[0]

For the print_r you have shown that you have an object:

RESPOSTA = stdClass Object (

That then has another object for the property ConsultarUsuarioResult :

[ConsultarUsuarioResult] => stdClass Object (

Where this object has a property called string which is a Array :

( [string] => Array (

I've placed online an example that builds an object identical to what it has and then extracts its value

    
01.08.2017 / 13:32