re: [PHP] How to read/write form/into certain place in a text fil e
| From: | STHK/Zh) | Date: | Mon, 07 Jan 2002 04:17:55 +0000 |
| Subject: | re: [PHP] How to read/write form/into certain place in a text fil e | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79652@lists.php.net to get a copy of this message | ||
Thank you ,Jimmy .
-----ÔʼÓʼþ-----
·¢¼þÈË: Jimmy [mailto:jimmy@spacedisk.com]
·¢ËÍʱ¼ä: 07 January, 2002 12:13
ÊÕ¼þÈË: php-general@lists.php.net
Ö÷Ìâ: Re: [PHP] How to read/write form/into certain place in a text file
Hi Leon,
> For example,read form letter 5 to 10 in line 4 ,and after some procedure
> ,write into the same place.
if the file is not too big, you can use file() function which will
return an array containing the content of the file per line.
combine this with substr() to read from specific column.
to write use substr_replace().
if the file is big, then doing file() is not advised, you should read
the file as stream. read the following functions:
fopen(), fclose(), fseek(), fread(), fwrite().
> Another question is that if a user has opened the file to read and write
,
> what will happen if another one will open and write the same file?
php doesnt handle file locking automatically, so i think it would
depend on the OS. if you want to handle file locking, read about flock().
--
Jimmy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
God is greater than your greatest problem
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net