How PHP parse object sdtClass [closed]

2019-02-28 13:43发布

问题:

When I run the SOAP client, I get the following response.

How can I parse this struct in php? I wanna take only NUGGETNAME value.

And how can take length of result count?

        object(stdClass)#2 (1) {
          ["GetHotelNuggetResult"]=>
          object(stdClass)#3 (1) {
            ["HotelNugget"]=>
            array(9) {
              [0]=>
              object(stdClass)#4 (7) {
                ["NUGGETNAME"]=>
                string(19) "Yaz Tatili Otelleri"
                ["NUGGETORDER"]=>
                string(2) "10"
                ["PARENTUNIQUECODE"]=>
                string(10) "AS_SOL_UST"
                ["REWRITENUGGETNAME"]=>
                string(19) "yaz-tatili-otelleri"
                ["TITLE"]=>
                string(19) "Yaz Tatili Otelleri"
                ["UNIQUECODE"]=>
                string(5) "YTOTL"
                ["WEBNUGGETID"]=>
                int(306)
              }
              .......//other results

              }
    }

回答1:

$O = response(....);
var_dump($O->GetHotelNuggetResult->HotelNugget[0]->NUGGETNAME);