Ok so first of all here is my problem:
I would like to read a text file and then format it to a SQL type of format.
So I tought, lets start it easy. What I am trying is to take a line and insert it into an array. Then output the array.
Simple right? Thats what I tought until, I realised the lines dont have the same number of datas. Some has 10, some has 5.
And there is also some lines that I need to split up a part and some that can stay toghter.
Well, I'll show you guys the code:
Code: Select all
<?PHP
$file_handle = fopen("players.txt", "rb");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode(' ', $line_of_text);
echo "$parts[0] $parts[1] $parts[2] $parts[3] $parts[4] $parts[5] $parts[6] $parts[7] $parts[8] $parts[9]<BR>";
}
fclose($file_handle);
?>
I will attach the text file that I would like to format.
But here is a sample of it:
3500
63 61 54 61 63 60 63 70 66 63
63 71 68 61 115 42 10 0 1 4 1
1973 24 6 950000 0 1991 4 17 98
0 0 0 0
0 0 0 0
179000 3000 908 0 0 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 0 0 0 0 0 0 0 0 0
0 0 0 0 4 194 7 3
0 0 0 0 0
-
Milan Hnilicka
drafted
150080070070075095144103068062125080125
1.16 (24.3.2002)
1.16 (24.3.2002)
0 0 98 65 70
This is the first player.
The 3500 at the top, is just to say that there is 3500 players, but it doenst matter too much.
Ok so here is the details:
The first 7 lines, I need to split them apart, each numbers = different strings = different colum name for the Database.
The lines 8,9 and 10 dont need it.
11 and 12 same as the first 7 ones.
Dont need 13, but need 14.
Dont need 15, 16, 17, 18, 19
But the line 20 need it like the first 7 ones.
But I would need to insert the lines I dont need anyways, as after that I would like to export the MYSQL data back into this format.
So can some one help me on doing this?
I am not sure if I am clear... If I aint please dont hesistate to ask more information...
Thanks for your help and Time,
Ara