Torben,

Just a side note:

I am continually amazed by the functionality that you and the rest of the
PHP development team put into PHP.  You have functions in PHP that would
take  a dozen lines for me to code in PERL and/or C.  Quite often, when I
think I've got to code some capability, I discover you have a function
already.

from those of us who have been pushing bits for a long time (30 years for
me), thanks...

rick

-----Original Message-----
From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 12:53 PM
To: cyberskydive
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] writing / reading from text files


On Fri, 2002-02-15 at 10:36, cyberskydive wrote:
> thanks guys,
> 
> there is just one more question I dont see an answer for anywhere I've
> looked.
> 
> will fseek read past \n's and if so how do I move the filepointer to a
> newline, or should I just put all the data on one line? (not unreasonable
n
> this case)

fseek() neither knows nor cares what the contents of the byte it's 
pointing to are--it's not even an error to seek beyond the ends of a
file, so watch your bounds checking. :) 

fread() will read a line at a time, and update the file pointer as it 
goes, and is the usual way of reading a file line-by-line.

A lot of file work in PHP is done with the file() function, which reads 
a file all at once, placing each line into its own array element. This
makes line processing very, very easy--dunno if that will help you in
this situation, though.


Torben
 
> "Rick Emery" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > from the manual:
> >
> > int fseek (int fp, int offset [, int whence])
> > Sets the file position indicator for the file referenced by fp.The new
> > position, measured in bytes from the beginning of the file, is obtained
by
> > adding offset to the position specified by whence, whose values are
> defined
> > as follows:
> > SEEK_SET - Set position equal to offset bytes.
> > SEEK_CUR - Set position to current location plus offset.
> > SEEK_END - Set position to end-of-file plus offset.
> >
> > -----Original Message-----
> > From: cyberskydive [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 15, 2002 10:43 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] writing / reading from text files
> >
> >
> > lol- so I use fseek() to move the file pointer before where I need to
> > write/replace/update a value? Is there a parameter for fseek to tell it
to
> > move to a newline, or stop after a certain bytes?
> > "Rick Emery" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > fopen(), fwrite(),fseek(),fread(),fclose()
> > >
> > > -----Original Message-----
> > > From: cyberskydive [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, February 15, 2002 10:29 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] writing / reading from text files
> > >
> > >
> > > I need to write to a specific line in a text file, read from a line on
> > > demand, and update values at random, I want to do this all in the same
> > text
> > > file.
> > >
> > > what is the best way to go about this?
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


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

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

Reply via email to