> For example:
> 
> while (!feof ($fp))
> 
> What does the ! mean or do?

! means not.

> What does feof mean? is it one command? or is f e o f all different?

feof() is a function that checks if a file has reached the end or not. (eof
= end of file)

while (!feof ($fp)) in whole means something like this
As long as the filepointer ($fp) is not at the end, do whatever that's
between { and } over and over again...

> Why are there 2 ) at the end?

Just because :-)
The first ) belongs to feof and the second ) belongs to while.

> 
> $buffer = fgets($fp, 4096);
> 
> Why does it need a buffer? What is a buffer?

$buffer is just a variable that stores the result of fgets(). It could be
any name really...

> 
> $arr = explode("|", $buffer);
> 
> It's questions like that. I can understand more or less what 
> the meanings
> are of the concepts. Another example of this is, I tested 
> your code, and it
> returned the string
> 
> SangiovanneseFlorentia Viola
> 
> on one line only. If I want it to look like this:?
> 
> Sangiovannese
> Florentia Viola
> 
> Now i now the \n means to go to the next line, but where 
> would I put that?

You modify this line
echo $arr[4];
to this
echo $arr[4] . "\n"; // The . is a string concatenation operator. It simply
joins the two strings.

Now this would give you the same result in your browser, but if you view the
source in the browser you will see that the lines are separated. To do a
line break in the browser you have to insert the correct html (<br>)
instead.

> You see my dilemmas no? I wish I could find a list of syntax 
> and functions
> like a reference guide. That would be a start

www.php.net/manual/en/ is a very good start.

> 
> Tack again
> -Tree

VarsŚgod!
Joakim

> 
> ----- Original Message -----
> From: Joakim Andersson <[EMAIL PROTECTED]>
> Newsgroups: php.general
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, September 12, 2002 4:54 PM
> Subject: RE: [PHP] Re: Cry for help
> 
> 
> > > |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
> 

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

Reply via email to