How Can I access to data in FlightInfoEx


#1

Hello,
I have done a request to FlightInfoEx and return me this structure, but, I can’t to read data. How Can I Access to destinationName (for example)? thanks.

Code: $result = $client->FlightInfoEx($params);

return:
stdClass Object ( [FlightInfoExResult] => stdClass Object ( [next_offset] => 1 [flights] => stdClass Object ( [faFlightID] => ANE8392-1498541195-airline-0137 [ident] => ANE8392 [aircrafttype] => CRK [filed_ete] => 00:45:00 [filed_time] => 1498541195 [filed_departuretime] => 1498729200 [filed_airspeed_kts] => 258 [filed_airspeed_mach] => [filed_altitude] => 0 [route] => [actualdeparturetime] => 0 [estimatedarrivaltime] => 1498732500 [actualarrivaltime] => 0 [diverted] => [origin] => LEMD [destination] => LEAL [originName] => Madrid-Barajas [originCity] => Madrid [destinationName] => Alicante [destinationCity] => Alicante / Benidorm / Costa Blanca ) ) ) Array ( [FlightInfoExResult] => stdClass Object ( [next_offset] => 1 [flights] => stdClass Object ( [faFlightID] => ANE8392-1498541195-airline-0137 [ident] => ANE8392 [aircrafttype] => CRK [filed_ete] => 00:45:00 [filed_time] => 1498541195 [filed_departuretime] => 1498729200 [filed_airspeed_kts] => 258 [filed_airspeed_mach] => [filed_altitude] => 0 [route] => [actualdeparturetime] => 0 [estimatedarrivaltime] => 1498732500 [actualarrivaltime] => 0 [diverted] => [origin] => LEMD [destination] => LEAL [originName] => Madrid-Barajas [originCity] => Madrid [destinationName] => Alicante [destinationCity] => Alicante / Benidorm / Costa Blanca ) ) )


#2

You will need to write the appropriate PHP code to navigate the multidimensional array. It’s probably similar to this (untested):


print $result"FlightInfoExResult"]"flights"][0]"destinationName"]


#3

Well, this is not returned as an array, but as an object. I am working to figure out the same thing


#4

In a nutshell, replace the square brackets “]” with “->”. Something like this ought to do the trick:

echo $result->FlightInfoExResult->flights->destinationName;