【问题标题】:Need to read this array in php [duplicate]需要在php中读取这个数组[重复]
【发布时间】:2019-08-18 08:26:09
【问题描述】:

我从一个soap 服务器接收一个stdClass 数组。但是我不明白怎么读。

我像一个简单的数组一样尝试它,但得到了这个错误

Cannot use object of type stdClass as 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
    }
}

【问题讨论】:

  • 不是一个数组,它实际上是一个对象。您需要做的就是访问对象的属性。你想了解 php 中的类和对象...

标签: php arrays soap


【解决方案1】:

那是因为它是一个对象,而不是一个数组。使用-> 访问数据。

这样

$nameOfStdClassVariable->RegistrarResult->BancaId

应该返回“WWW”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多