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

From: Date: Mon, 07 Jan 2002 04:13:08 +0000
Subject: Re: How to read/write form/into certain place in a text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-79651@lists.php.net to get a copy of this message
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

« previous php.general (#79651) next »