-1

I am receiving a stdClass array from a soap server. But I don't understand how to read it.

I try it like a simple array but got this error

Cannot use object of type stdClass as array

This is the array:

object(stdClass)#2 (1) {
  ["RegistrarResult"]=>
  object(stdClass)#3 (23) {`enter code here`
    ["Anio"]=>
    NULL
    ["BancaId"]=>
    string(3) "WWW"
    ["Cedula"]=>
    string(11) "SSSS"
    ["CodigoConsorcio"]=>
    string(5) "EEEE"
    ["Color"]=>
    NULL
    ["Error"]=>
    NULL
    }
}
ivion
  • 567
  • 1
  • 9
  • 14
  • This is _not_ an array, it actually is an object. All you need to do is access the object's properties. You want to read about classes and objects in php... – arkascha Mar 27 '19 at 17:24

1 Answers1

0

That is because it is an object, not an array. Use -> to access the data.

Like this

$nameOfStdClassVariable->RegistrarResult->BancaId

Should return "WWW"

Mathias Dam
  • 107
  • 1
  • 4