I am trying to figure out how to filter an object based on a comparison.
I get an object that looks something like this, although with 15 results....
stdClass Object
(
[FlightInfoExResult] => stdClass Object
(
[next_offset] => 15
[flights] => Array
(
[0] => stdClass Object
(
[faFlightID] => SWA2078-1499232401-airline-0885
[ident] => SWA2078
[aircrafttype] => B738
[filed_ete] => 03:00:00
[filed_time] => 1499232401
[filed_departuretime] => 1499477700
[filed_airspeed_kts] => 423
[filed_airspeed_mach] =>
[filed_altitude] => 0
[route] =>
[actualdeparturetime] => 0
[estimatedarrivaltime] => 1499489100
[actualarrivaltime] => 0
[diverted] =>
[origin] => KPHX
[destination] => KMKE
[originName] => Phoenix Sky Harbor Intl
[originCity] => Phoenix, AZ
[destinationName] => General Mitchell Intl
i need to filter this object so only return the [flights]
where [filed_departuretime]
is within 1 hour of Query result $time = strtotime($item['departure_time']);
by doing something like this:
abs($object->filed_departuretime - $time) <= 3600)
hopefully this all makes sense, thanks for your help :) I dont really know how array_filter works so this is what I have so far....
//set flight identity
$ident = $item['airline'].$item['flight_number'];
$date = date('Y-m-d H:i:s');
$time = strtotime($item['departure_time']);
//get flightaware results
$flightAwareResult = FlightInfoEx($ident);
/*$flightResult = array_filter(
$flightAwareResult,
);*/