Re: external file
| From: | David Robley | Date: | Thu, 25 May 2000 05:48:46 +0000 |
| Subject: | Re: external file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-506@lists.php.net to get a copy of this message | ||
On 24 May, Eric Porter wrote:
> I have a file on the server i want to manipulate.
> Here is the goal. I want to open the file, select
> the first line insert this line into a table,
> then delete this line in the external file.
> Sounds easy right? If someone has a example that
> would be great.
>
> Thanks agian list.
> Eric
How about something like:
open the file for read
use fgets to read the first line
add the result to <table>
use fgets to read the rest of the file to $string
close the file
open the file for write
(Note this trashes the file so you might want some sort of check to
ensure everything so far is OK. Or maybe you could open a new file and
when you are sure everything is OK copy it to the old file)
use fputs to write $string to the file
close the file
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA