Extract Key Result

Asked

Viewed 34 times

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 answer 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 in $variables

I’m trying so, but without success.

But my real problem , is that I can’t extract the values from the keys, to store in variables

Attempts .......

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

Not Even So.........

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

. . . What would be the solution ?

1 answer

1


The correct way to use it would be:

$resultado->ConsultarUsuarioResult->string[0]

For the print_r that showed we see that it has an object:

RESPOSTA = stdClass Object (

Who 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 (

Placed online an example that builds an object identical to what you have and then extracts its value

  • SOLVED ! Thank you , Isac

Browser other questions tagged

You are not signed in. Login or sign up in order to post.