Hello…
I get content of file and echo it with numbers, times, interval. Line after line. I have to make all lines echoed with green color, excluding last 8. Last 8 should be black. I could easly set some “if” case but file is generated live and dynamically. That means after more people making entry into file from which I receive data it would be false.
Preview: http://tourney.adrenalinex.co.uk/rounds/r2.php
[php]<?
function format_time($t) {
$minutes = floor($t / 60000);
$seconds = sprintf(’%02d’,floor(($t / 1000) % 60));
$ms = sprintf(’%03d’, $t % 1000);
return $minutes . “:” . $seconds . “.” . $ms;
}
$highscores = file_get_contents(‘http://highscores.adrenalinex.co.uk/tourney4.php?c=1&r=2’);
$lines = explode("\n", $highscores);
$x=0;
echo “<table style=“text-align: center; font-weight: bold; border: 1px solid #CCC;” border=“1” cellpadding=“4” align=“center”>
<td style=“background: url(‘wp-content/themes/arras/images/feed-title-white.jpg’); font-weight: bold; color: red; width: 40px;”> <td style=“background: url(‘wp-content/themes/arras/images/feed-title-white.jpg’); font-weight: bold; color: red; width: 200px;”>Drivers Name<td style=“background: url(‘wp-content/themes/arras/images/feed-title-white.jpg’); font-weight: bold; color: red; width: 100px;”>Time<td style=“background: url(‘wp-content/themes/arras/images/feed-title-white.jpg’); font-weight: bold; color: red; width: 100px;”>Interval to 1st<td style=“background: url(‘wp-content/themes/arras/images/feed-title-white.jpg’); font-weight: bold; color: red; width: 100px;”>Interval to driver ahead
”;
foreach ($lines as &$line) {
if ($x>0) {
echo "
$x |
$names
|
";
echo format_time($times[$x]);
echo " |
";
if ($x>1) {
echo "+ " . format_time($times[$x] - $times[1]);
} else {
echo "-";
}
echo " |
";
if ($x>1) {
echo "+ " . format_time($times[$x] - $times[$x-1]);
} else {
echo "-";
}
echo " |
";
}
$x++;
list($names, $times[$x]) = sscanf($line, "%s %d");
}
echo "";
?>[/php]