How do I print the data within this nested stdClass Object?

无人久伴 提交于 2019-12-25 07:26:44

问题


I am attempting to print values within this nested stdClass Object but I'm having trouble accessing them. How do I print, for example, the value of "originCity"?

stdClass Object (
    [FlightInfoResult] => stdClass Object (
        [next_offset] => 1 
        [flights] => stdClass Object (
            [ident] => SWA2558
            [aircrafttype] => B737
            [filed_ete] => 00:50:00
            [filed_time] => 1362879561
            [filed_departuretime] => 1362880080
            [filed_airspeed_kts] => 442
            [filed_airspeed_mach] => 
            [filed_altitude] => 410
            [route] => LBY MEI J31 VUZ
            [actualdeparturetime] => 1362880080
            [estimatedarrivaltime] => 1362882900
            [actualarrivaltime] => 1362882600
            [diverted] => [origin] => KMSY
            [destination] => KBHM
            [originName] => New Orleans Intl
            [originCity] => New Orleans, LA
            [destinationName] => Birmingham-Shuttlesworth Intl
            [destinationCity] => Birmingham, AL
        )
    )
)

回答1:


Try

$var->FlightInfoResult->flights->originCity



回答2:


you can use

$object->FlightInfoResult->flights->originCity;

to access objects properties.

sorry about that.



来源:https://stackoverflow.com/questions/15560742/how-do-i-print-the-data-within-this-nested-stdclass-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!