In the test script i sent, the array with the track names, has the track distance too, it's the last parameter.
<?php
php
$idk = 'IDENT KEY HERE';
$trackCodes = array(
0 => 'Blackwood',
1 => 'South City',
2 => 'Fern Bay',
3 => 'Autocross',
4 => 'Kyoto Ring',
5 => 'Westhill',
6 => 'Aston'
);
$configCodes = array(
'00' => 'GP',
'01' => 'Rallycross',
'02' => 'Car Park',
'10' => 'Classic',
'11' => 'Sprint 1',
'12' => 'Sprint 2',
'13' => 'Long',
'14' => 'Town',
'20' => 'Club',
'21' => 'Green',
'22' => 'Gold',
'23' => 'Black',
'24' => 'Rallycross',
'25' => 'RallyX Green',
'30' => 'Autocross',
'31' => 'Skid Pad',
'32' => 'Drag Strip',
'33' => 'Eight Lane Drag',
'40' => 'Oval',
'41' => 'National',
'42' => 'GP Long',
'50' => 'International',
'60' => 'Cadet',
'61' => 'Club',
'62' => 'National',
'63' => 'Historic',
'64' => 'Grand Prix',
'65' => 'Grand Touring',
'66' => 'North'
);
$configLengths = array(
'00' => 2.1,
'01' => 1.2,
'02' => 0.2,
'10' => 1.3,
'11' => 1.3,
'12' => 0.8,
'13' => 2.5,
'14' => 2,
'20' => 1,
'21' => 1.9,
'22' => 2.2,
'23' => 4.1,
'24' => 1.3,
'25' => 0.5,
'30' => 0.3,
'31' => 0.1,
'32' => 0.7,
'33' => 0.7,
'40' => 1.9,
'41' => 3.2,
'42' => 4.6,
'50' => 3.2,
'60' => 1.2,
'61' => 1.9,
'62' => 3.5,
'63' => 5,
'64' => 5.5,
'65' => 5,
'66' => 3.2
);
include "LFSWorldSDK2.php";
$LFSWorld = new LFSWorldSDK($idk);
$pbArray = $LFSWorld->get_pb($_GET['racer']);
$tracksArray = array();
$configsArray = array();
$carsArray = array();
foreach($pbArray as $key => $subArray)
{
$tracksArray[$subArray['track'][0]]['lapcount'] += $subArray['lapcount'];
$configsArray[$subArray['track']]['lapcount'] += $subArray['lapcount'];
$carsArray[$subArray['car']]['lapcount'] += $subArray['lapcount'];
$tracksArray[$subArray['track'][0]]['miles'] += $subArray['lapcount'] * $configLengths[substr($subArray['track'],0,2)];
$configsArray[$subArray['track']]['miles'] += $subArray['lapcount'] * $configLengths[substr($subArray['track'],0,2)];
$carsArray[$subArray['car']]['miles'] += $subArray['lapcount'] * $configLengths[substr($subArray['track'],0,2)];
}
$string = "<table>\n\t<tr>\n\t\t<th align=\"center\" colspan=\"3\">Track Environments</th>\n\t</tr>";
arsort($tracksArray);
foreach($tracksArray as $key => $subArray)
{
if($subArray['lapcount'] === 0)
{
continue;
}
$subArray['miles'] = round($subArray['miles']);
$string .= "\n\t<tr>\n\t\t<td align=\"left\" width=\"200px\">{$trackCodes[$key]}</td>\n\t\t<td align=\"right\" width=\"100px\">{$subArray['lapcount']} laps</td>\n\t\t<td align=\"right\" width=\"100px\">{$subArray['miles']} miles</td>\n\t</tr>";
}
$string .= "\n\t<tr>\n\t\t<th colspan=\"3\">Track Configurations</th>\n\t</tr>";
arsort($configsArray);
foreach($configsArray as $key => $subArray)
{
if($subArray['lapcount'] === 0)
{
continue;
}
$configName = $trackCodes[substr($key,0,1)] . ' ' . $configCodes[substr($key,0,2)];
$subArray['miles'] = round($subArray['miles']);
if(substr($key,2) == 1)
{
$configName .= ' Rev';
}
$string .= "\n\t<tr>\n\t\t<td align=\"left\">$configName</td>\n\t\t<td align=\"right\">{$subArray['lapcount']} laps</td>\n\t\t<td align=\"right\" width=\"100px\">{$subArray['miles']} miles</td>\n\t</tr>";
}
$string .= "\n\t<tr>\n\t\t<th colspan=\"3\">Car Names</th>\n\t</tr>";
arsort($carsArray);
foreach($carsArray as $key => $subArray)
{
if($subArray['lapcount'] === 0)
{
continue;
}
$subArray['miles'] = round($subArray['miles']);
$string .= "\n\t<tr>\n\t\t<td align=\"left\">$key</td>\n\t\t<td align=\"right\">{$subArray['lapcount']} laps</td>\n\t\t<td align=\"right\" width=\"100px\">{$subArray['miles']} miles</td>\n\t</tr>";
}
$string .= "\n</table>";
echo $string;
?>
C:\>cd php
C:\>cd php
C:\PHP>php test1.php
<PHP code would be outputted here>