Thanks man!!!!!!!!!!!!
THat worked like a champ!
is this what removed the , and made it 2 strings?
Code: Select all
// spilt each line into individual fields
$names = explode(",", $line);
Let me ask you this question now. This seems like it can save me some typing on the rest of this.
Here is what I have.
Code: Select all
; 1999 Week 17 99WK17QO.NFL QSS Offensive Player Stats
; |-------- Passing --------|-- Rushing --|- Receiving -|- Kicking FG Distances -|
; 2- 2- 2- 01 30 40
;Name ID # Tm/ID Pos I S P T Cmp Att Yds In TD Pt Sck/Yds Car Yds TD Pt Rec Yds TD Pt EPM EPA FGM FGA -29 -39 -49 50+ FL TDs by distance
Aguiar, Louie 3024 GB 9021 P 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Aikman, Troy 2 DAL 9014 QB 1 1 0 23 32 288 0 2 0 0 0 3 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 T004T090
Akers, David 1594 PHI 9016 PK 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 G046
Alexander, Derrick 1020 KC 9010 WR 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 18 0 0 0 0 0 0 0 0 0 0 0
Alexander, Stephen 1504 WAS 9018 TE 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 38 0 0 0 0 0 0 0 0 0 0 0
Alford, Brian 1513 NYG 9015 WR 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 7 1 0 0 0 0 0 0 0 0 0 0 C007
This is how I am parsing this out getting ready to put it in a DB.
Code: Select all
$offPlayers = "./nfl.txt" ;
if (!($fp = fopen($offPlayers, "r"))) die ("Cannot open file");
$player = fgets($fp);
$player = fgets($fp);
$player = fgets($fp);
$player = fgets($fp);
do
{
$fullname = fread($fp,25);
$fullname = trim($fullname);
echo "name",$fullname;
$offset = fgetc($fp);
$id = fread($fp, 4);
$id = trim($id);
echo "ID",$id;
$offset = fgetc($fp);
$team = fread($fp, 3);
$team = trim($team);
echo "Team",$team;
$offset = fgetc($fp);
$teamid = fread($fp, 4);
$teamid = trim($teamid);
echo "Team ID",$teamid;
$offset = fgetc($fp);
$pos = fread($fp, 2);
$pos = trim($pos);
echo "Posistion",$pos;
$offset = fgetc($fp);
$inj_stat = fread($fp, 1);
$inj_stat = trim($inj_stat);
echo "Injury",$inj_stat;
$offset = fgetc($fp);
$start = fread($fp, 1);
$start = trim($start);
echo "Started",$start;
$offset = fgetc($fp);
$played = fread($fp, 1);
$played = trim($played);
echo "Played",$played;
$offset = fgetc($fp);
$inact = fread($fp, 1);
$inact = trim($inact);
echo "Inactive",$inact;
$offset = fgetc($fp);
$pcmp = fread($fp, 3);
$pcmp = trim($pcmp);
echo "Completions",$pcmp;
$offset = fgetc($fp);
$patt = fread($fp, 3);
$patt = trim($patt);
echo "Attempts",$patt;
$offset = fgetc($fp);
$pyds = fread($fp, 3);
$pyds = trim($pyds);
echo "Passing Yards",$pyds;
$offset = fgetc($fp);
$pint = fread($fp, 2);
$pint = trim($pint);
echo "Interceptions",$pint;
$offset = fgetc($fp);
$ptds = fread($fp, 2);
$ptds = trim($ptds);
echo "TDS",$ptds;
$offset = fgetc($fp);
$p2pt = fread($fp, 2);
$p2pt = trim($p2pt);
echo "2points",$p2pt;
$offset = fgetc($fp);
$psck = fread($fp, 3);
$psck = trim($psck);
echo "Sacked",$psck;
$offset = fgetc($fp);
$psckyds = fread($fp, 3);
$psckyds = trim($psckyds);
echo "YDS",$psckyds;
$offset = fgetc($fp);
$car = fread($fp, 3);
$car = trim($car);
echo "carries",$car;
$offset = fgetc($fp);
$ryds = fread($fp, 3);
$ryds = trim($ryds);
echo "rushing yds",$ryds;
$offset = fgetc($fp);
$rtds = fread($fp, 2);
$rtds = trim($rtds);
echo "rushing tds",$rtds;
$offset = fgetc($fp);
$r2pt = fread($fp, 2);
$r2pt = trim($r2pt);
echo "Rush 2pts",$r2pt;
$offset = fgetc($fp);
$rec = fread($fp, 3);
$rec = trim($rec);
echo "Receptions",$rec;
$offset = fgetc($fp);
$recyds = fread($fp, 3);
$recyds = trim($recyds);
echo "Reception yds" , $recyds;
$offset = fgetc($fp);
$rectds = fread($fp, 2);
$rectds = trim($rectds);
echo "Reception tds" , $rectds;
$query = "INSERT INTO $dbtable (Name) VALUES ('$fullname')";
$result = mysql_query($query);
$player = fgets($fp);
echo "<br>";
}
while(!Feof($fp));
fclose($fp);
That is a whole lot of typing. Is there a way I can do the same thing with what you just did? One colum has no number or letters in it so I am not sure how that would work either.