Grabbing multiple informations from one request.


#1

Hi everyone! I have some questions on how to do this.

$params = array(
“fleet” => ‘FDX’,
“howMany” => 1,
“offset” => 0);
$result = $client->FleetScheduled($params);
$arr = $result->FleetScheduledResult->scheduled->destination;
print_r($arr);

That works fine.

$params = array(
“fleet” => ‘FDX’,
“howMany” => 2,
“offset” => 0);
$result = $client->FleetScheduled($params);
$arr = $result->FleetScheduledResult->scheduled->destination;
print_r($arr);

As soon as i request 2+ then nothing is displayed, is there a better way to access the information that is being returned? Thanks for all your help in advance.

Julie


#2

Although the request for multiple flights is working, your assignment of the result is where your failure is occurring.



$arr = $result->FleetScheduledResult->scheduled->destination;


When multiple results are returned, $result->FleetScheduledResult->scheduled will be an array and you will need to use square-brackets to access each destination. I recommend you do something like this:



// set the maximum results allowed on this account.
$params = array("max_size" => 100);
$result = $client->SetMaximumResultSize($params);
#print_r($result);


// get the flights.
$params = array("fleet" => "FDX", "howMany" => 75, "offset" => 0);
$result = $client->FleetScheduled($params);
foreach ($result->FleetScheduledResult->scheduled as $flight) {
  if ($flight->destination == "KMEM") {
    print $flight->ident . "
";
    #print_r($flight); 
  }
}