RE: [PHP] Re: Cry for help

From: Date: Thu, 12 Sep 2002 14:54:03 +0000
Subject: RE: [PHP] Re: Cry for help
Groups: php.general 
Request: Send a blank email to php-general+get-116162@lists.php.net to get a copy of this message
> |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. Regards Joakim Andersson

« previous php.general (#116162) next »