【问题标题】:Extraction of data from Soap Response in Php从 PHP 中的 Soap Response 中提取数据
【发布时间】:2015-08-04 15:30:27
【问题描述】:

我使用 PHP 脚本 执行了 SOAP/WSDL 请求。 我可以访问如下所示的答案:

stdClass Object
(
     [inventory] => 
     (
        [0] => stdClass Object
               (
                [location_inventory] => stdClass Object
                    (
                        [location] => stdClass Object
                            (
                                [organization] => abcdef
                                [contact] => stdClass Object
                                    (
                                        [contact_details] => stdClass Object
                                            (
                                                [id] => Thomas
                                            )
                                    )
                            )
                        [product] => tomatoes
                    )
            )
    )
)

关键是我无法提取变量“organization”、“id”或“product”。

访问 stdClass ObjectArray 的语法有何不同?

【问题讨论】:

  • $data->inventory[0]->location_inventory->location->organization 等等

标签: php xml soap xml-parsing soap-client


【解决方案1】:

我猜你正在使用json_decode 来获取你展示的对象。 如果是这种情况,请尝试使用json_decode( $data, true);,它将返回一个正确的数组,如文档中所述:here

这样您就可以通过正常的数组方式访问您的数据:$data['inventory']...

希望有帮助

【讨论】:

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