re: [PHP] How to read/write form/into certain place in a text file

2002-01-06 Thread Zhang, Leon (STHK/Zh)

Thank you ,Jimmy .



-ԭʼÓʼþ-
·¢¼þÈË: Jimmy [mailto:[EMAIL PROTECTED]]
·¢ËÍʱ¼ä: 07 January, 2002 12:13
ÊÕ¼þÈË: [EMAIL PROTECTED]
Ö÷Ìâ: 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to read/write form/into certain place in a text file

2002-01-06 Thread Jimmy

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




re: [PHP] How to read/write form/into certain place in a text file

2002-01-06 Thread Zhang, Leon (STHK/Zh)



Does anybody know 
this?
Please give me 
some advice,any help will be appreciated.

  -ԭʼÓʼþ-·¢¼þÈË: Zhang, Leon (STHK/Zh) 
  [mailto:[EMAIL PROTECTED]]·¢ËÍʱ¼ä: 07 January, 2002 
  9:56ÊÕ¼þÈË: [EMAIL PROTECTED]Ö÷Ìâ: [PHP] How to 
  read/write form/into certain place in a text file
  hi,
     A text file has 
  been formatted ,how to read/write form/into certain place in a text 
  file.
  For example,read form letter 
  5 to 10 in line 4 ,and after some procedure ,write into the same 
  place.
    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?
    Thank you in 
  advance.
   
  Leon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]