> |Serie C2 Round 2|09.09.02|20.45|Sangiovannese|Florentia Viola
> |Serie C2 Round 2|09.09.02|20.45|Gualdo|Florentia Viola
> So for example, lets say I wanted to make another html form 
> that has a form
> field for List team by: and and select either "home" or "away" ... by
> selecting "home", the browser would print out the following:
> Sangiovannese
> Gualdo
> so now I need to figure out how to get PHP to do the following:
> #1 look at each line in the text file and treat it individually
> #2 select the data after the 4th | from each line
> #3 print it back to the browser

$fd = fopen ("/tmp/inputfile.txt", "r"); // Opens file for reading
while (!feof ($fd)) // Start of loop.
    $buffer = fgets($fd, 4096); // Reads one line of maximum 4096 bytes
    $arr = explode("|", $buffer); // Divides each row into separate elements
in an array.
    echo $arr[4]; // Prints the 5th element of each row.
// The first element ($arr[0]) is actually "" (an empty string) since each
line starts with |.
fclose ($fd);

Hopefully this will get you in the right direction.
Joakim Andersson

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to