簡體   English   中英

如何從PHP print_r()提供的信息中重建對象

[英]How to reconstruct object from information given by PHP print_r()

在使用PHP SoapClient調用服務方法后,我得到了返回值$ result,當print_r($result)給出時:

stdClass Object
(
    [GetDataRowResult] => stdClass Object
        (
            [FieldValueList] => stdClass Object
                (
                    [FieldValuePair] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [Field] => Name
                                    [Value] => Christmas Party
                                )

                            [1] => stdClass Object
                                (
                                    [Field] => Status
                                    [Value] => 3
                                )

                            [2] => stdClass Object
                                (
                                    [Field] => StartDate
                                    [Value] => 18/12/2009 12:00 AM
                                )

                            [3] => stdClass Object
                                (
                                    [Field] => EndDate
                                    [Value] => 01/01/1900 12:00 AM
                                )

                        )

                )

            [Message] => 
            [Success] => 1
        )

)

我想使用狀態值來做某事,但我不知道如何獲得該值。 我嘗試了 $result->GetDataRowResult->FieldValueList->FieldValuePair[1]->Value ,但它不起作用,這是我所期望的。 編輯 :它確實工作了,我在代碼中還有另一個錯別字錯誤,其他地方導致它出錯

如何獲得所需的值,是否有更好的方法將整個輸出重構為PHP對象?

用這個

$result->GetDataRowResult->FieldValueList->FieldValuePair->1->Value

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM