Thank you all for your replies.
Great work, ImperialOutpost it has lead me in the right direction.
Another question is how do I skip the first 5 lines (because they contain no relevant data) as an example. I've tried creating a loop and also tried fseek but perhaps I'm missing something.
There is really no fixed layout, I'll need to id the lines via the numbers for insertion into a mysql database, but thats later. For now I would like to see if it is possible to skip "X" amount of lines.
$fileName="100430A.TXT";
$openFile = fopen($fileName, "r") or die ("Unable to open the file $filename");
$rank = 1;
while( !feof($openFile) ) {
//example i would like to skip the first 14 lines, can't find a php function that will do this
$dirtyLine = fgets($openFile);
$sPattern = '/\s\s+/';
$sReplace = ' ';
$dirtyLine = preg_replace($sPattern, $sReplace, $dirtyLine);
$lines2 = explode(' ',$dirtyLine);
switch($rank) {
case 1:
$rank_ico = 'gold: ';
break;
case 2:
$rank_ico = 'silver: ';
break;
case 3:
$rank_ico = 'bronze: ';
break;
default:
$rank_ico = '';
}
if(!empty($lines2[15])) { $percents = $lines2[15]; } else { $percents = ' ';}
if(!empty($lines2[16])) { $masterpts = $lines2[16]; } else { $masterpts = ' ';}
echo '
<tr>
<td>'.$rank_ico.$rank.'</td>
<td>'.$lines2[1].'</td>
<td>'.$lines2[2].' '.$lines2[3].' & '.$lines2[4].' '.$lines2[5].'</td>
<td>'.$lines2[6].'</td>
<td>'.$lines2[7].' '.$lines2[8].' '.$lines2[9].'</td>
<td>'.$lines2[11].' '.$lines2[12].' '.$lines2[13].'</td>
<td>'.$lines2[14].'</td>
<td>'.$percents.'</td>
<td>'.$masterpts.'</td>
</tr>
';
$rank++;
}
fclose($openFile);