October 7, 2018

masterpointstext

[insert_php]
// open the text file
// set style for black text
echo(‘

‘);
$f = fopen(“http://www.southorangecountybridge.center/Results/MONTHMP.TXT”,”r”);
$loopcnt = -1;
$mpnames = array();
$mppoints = array();
// while loop to get text line by line
while ($line = fgets($f)) {
$loopcnt ++;
if ($loopcnt>0) {
$line = trim($line);
$pos = strpos($line, ” “);
// remove extraneous spaces
// !== means not equal
// strpos returns position or false if not found
while ($pos !== false) {
$pos = strpos($line, ” “);
$line = str_replace(” “, ” “, $line);
}
// string split
$p = explode (” “, $line);
$pcount = count($p);
if ($pcount > 2) {
//$line = str_replace(” “, “,”, $line);
//echo($line.’
‘);
//echo($p[1].’: ‘);
// $na = names
$na = “”;
for ($x = 2; $x < $pcount; $x++) { $na .= $p[$x].' '; } //echo($na.'
‘);
$indx = $loopcnt – 1;
$mpnames[$indx] = $na.’,’.$p[1];
$mppoints[$indx] = $p[1].”,”.$na;
}
} else {
//processes first line
$pos1 = strpos($line, “Page”);
if ($pos1 !== false) {
$line = substr($line, 0, $pos1);
}
$line = substr($line, 0 , 12).’ — ‘.substr($line, 12);
$line = trim($line);
echo ($line);

}
}
// close the file
fclose($f);

// start with column 2 first for formatting anomoly
echo(‘

‘);
echo(‘
‘);
echo(‘

Sorted by Name

‘);
echo(‘

    ‘);
    sort($mpnames);
    $mpcount = count($mpnames);
    for ($y=1; $y < $mpcount; $y++) { $mpnames[$y] = str_replace(","," --- ", $mpnames[$y]); echo('
  • ‘.$mpnames[$y].’
  • ‘);
    }
    echo(‘

‘);
echo(‘

‘);

echo(‘

‘);
echo(‘

Sorted by Masterpoints

‘);
echo(‘

    ‘);
    $mpcount = count($mppoints);
    for ($y=0; $y < $mpcount; $y++) { $mppoints[$y] = str_replace(","," --- ", $mppoints[$y]); echo('
  • ‘.$mppoints[$y].’
  • ‘);
    }
    echo(‘

‘);
echo(‘

‘);
[/insert_php]