Sure, first thing, everything is returned as objects from the API, unless there’s multiple rows.
We can check out GetLastReports()
It’s plural, so it’ll return a list.
So we can do (I’m just using 1 to return the reports from user number 1)
<?php
$lastreport = PIREPData::GetLastReports(1, 1);
print_r($lastreport);
Which will show this:
stdClass Object
(
[pirepid] => 65
[pilotid] => 1
[code] => ABC
[flightnum] => 38
[depicao] => LFPG
[arricao] => KJFK
[aircraft] => 4
[flighttime] => 5.3
[distance] => 0
[submitdate] => 2008-12-21 10:04:16
[accepted] => 2
[log] =>
[load] => 24000
[price] => 5
[flighttype] => C
[pilotpay] => 120
)
We can see it says “stdClass Object”, so it returned an object
So now we can do:
<?php
echo $lastreport->depicao; /// Will say "LFPG"
?>
Now let’s return the last 2 reports..
<?php
$lastreport = PIREPData::GetLastReports(1, 2);
print_r($lastreport);
Which will echo out:
Array
(
[list][*] => stdClass Object[/list]
(
[pirepid] => 65
[pilotid] => 1
[code] => ABC
[flightnum] => 38
[depicao] => LFPG
[arricao] => KJFK
[aircraft] => 4
[flighttime] => 5.3
[distance] => 0
[submitdate] => 2008-12-21 10:04:16
[accepted] => 2
[log] =>
[load] => 24000
[price] => 5
[flighttype] => C
[pilotpay] => 120
)
[1] => stdClass Object
(
[pirepid] => 61
[pilotid] => 1
[code] => ABC
[flightnum] => 4004
[depicao] => KORD
[arricao] => KDTW
[aircraft] => 2
[flighttime] => 5.3
[distance] => 0
[submitdate] => 2008-11-30 20:25:35
[accepted] => 1
[log] =>
[load] => 77
[price] => 140
[flighttype] => P
[pilotpay] => 120
)
)
This one says “Array”, and there’s results in => …, and [1] => …, meaning the first value (0) has the first report, then the second (1) has the second report. Numbering starts from 0
Now do mess with this we do:
<?php
// This will loop through each one, and assign each report, one
// at a time, to $report
foreach($lastreport as $report)
{
// Now we use $report as a normal object
echo $report->depicao .'<br />';
}
Which will output:
LFPG
KORD
All the API functions operate this way
Hopefully that helps!