RE: [PHP] writing / reading from text files
| From: | Rick Emery | Date: | Fri, 15 Feb 2002 18:48:12 +0000 |
| Subject: | RE: [PHP] writing / reading from text files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-84959@lists.php.net to get a copy of this message | ||
from the manual:
fgets -- Gets line from file pointer
Description
string fgets (int fp, int length)
Returns a string of up to length - 1 bytes read from the file pointed to by
fp. Reading ends when length - 1 bytes have been read, on a newline (which
is included in the return value), or on EOF (whichever comes first).
If an error occurs, returns FALSE.
The file pointer must be valid, and must point to a file successfully opened
by fopen(), popen(), or fsockopen().
fputs -- Writes to a file pointer
Description
int fputs (int fp, string str [, int length])
fputs() is an alias to fwrite(), and is identical in every way. Note that
the length parameter is optional and if not specified the entire string will
be written
-----Original Message-----
From: cyberskydive [mailto:cyberskydive@sunraydesigns.com]
Sent: Friday, February 15, 2002 12:36 PM
To: php-general@lists.php.net
Subject: Re: [PHP] writing / reading from text files
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)
"Rick Emery" <remery@excel.com> wrote in message
news:EAA093B474ABD311A71E00508B5FE08305C2D1C3@adntex03.us.excel.com...
> 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:cyberskydive@sunraydesigns.com]
> Sent: Friday, February 15, 2002 10:43 AM
> To: php-general@lists.php.net
> 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" <remery@excel.com> wrote in message
>
> news:EAA093B474ABD311A71E00508B5FE08305C2D1C2@adntex03.us.excel.com...
> > fopen(), fwrite(),fseek(),fread(),fclose()
> >
> > -----Original Message-----
> > From: cyberskydive [mailto:cyberskydive@sunraydesigns.com]
> > Sent: Friday, February 15, 2002 10:29 AM
> > To: php-general@lists.php.net
> > 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