Hi,
I was trying to do the following. It's my first php "project", so it's quiet
logic that i have some problems. Perhaps the php community might help. It's
about this :
I have a txt file with the following data :
1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich 2.37; 4. John
Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;
It's a ranking of a race. Now what i want to reach is, that these names,
come into an array, eventually in an sql database. But the last thing, is
not this big problem, if I succeed in getting it into an array.
So the result might look something like this
Stijn Piot
Kim Van Rooy
....
It would be even cooler, if in front of these names was
1 | Stijn Piot | 58.12
2 | Kim Van Rooy | 1.28
3 | .... | 2.54
....
10| John Terlaeken | 1 ronde/tour/round behind
Now the last thing, I didn't tried, because it seems to complicated for my
first "project". The first however must be possible, and it can't be that
difficult. This is what I had, but it didn't worked. Can somebody help me to
reach the exact result. Thankx in advance
<? php
$textfile = "1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich
2.37; 4. John Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;"
// this is a part of the textfile
$position=split ("\;", $textfile); //splitting in an array with the
semicolon, the result is an array with rows like this 1. stijn piot 58.12
$max = count($position ); // counting the size of the array
$i =0;
For ($i=0; $i<$max; $i++) {
$time = split ("^[0-9]+\.[[:space:]]", $position[$i]); // the row 1.
stijn piot 58.12 is splitted according "number space", the result is stijn
piot 58.12
$name = split ("[0-9]+\.[0-9]+", $time[1]);
echo $name[0]; // the previous result stijn piot 58.12 is splitted
according "number.number" , the final result should be stijn piot
}
// because it is a for loop, eventually i should have
//stijn piot
//kim van rooy
//.... but the farest i can get is just stijn piot and further nothing.
?>
It's not easy at all, i hope the community can do something for me. I'm sure
that this script can help quiet a lot of people. ;)
Ciao
Stijn
I was trying to do the following. It's my first php "project", so it's quiet
logic that i have some problems. Perhaps the php community might help. It's
about this :
I have a txt file with the following data :
1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich 2.37; 4. John
Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;
It's a ranking of a race. Now what i want to reach is, that these names,
come into an array, eventually in an sql database. But the last thing, is
not this big problem, if I succeed in getting it into an array.
So the result might look something like this
Stijn Piot
Kim Van Rooy
....
It would be even cooler, if in front of these names was
1 | Stijn Piot | 58.12
2 | Kim Van Rooy | 1.28
3 | .... | 2.54
....
10| John Terlaeken | 1 ronde/tour/round behind
Now the last thing, I didn't tried, because it seems to complicated for my
first "project". The first however must be possible, and it can't be that
difficult. This is what I had, but it didn't worked. Can somebody help me to
reach the exact result. Thankx in advance
<? php
$textfile = "1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich
2.37; 4. John Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;"
// this is a part of the textfile
$position=split ("\;", $textfile); //splitting in an array with the
semicolon, the result is an array with rows like this 1. stijn piot 58.12
$max = count($position ); // counting the size of the array
$i =0;
For ($i=0; $i<$max; $i++) {
$time = split ("^[0-9]+\.[[:space:]]", $position[$i]); // the row 1.
stijn piot 58.12 is splitted according "number space", the result is stijn
piot 58.12
$name = split ("[0-9]+\.[0-9]+", $time[1]);
echo $name[0]; // the previous result stijn piot 58.12 is splitted
according "number.number" , the final result should be stijn piot
}
// because it is a for loop, eventually i should have
//stijn piot
//kim van rooy
//.... but the farest i can get is just stijn piot and further nothing.
?>
It's not easy at all, i hope the community can do something for me. I'm sure
that this script can help quiet a lot of people. ;)
Ciao
Stijn
Comment