Re: overwriting file record
| From: | DLau | Date: | Fri, 18 Oct 2002 05:40:50 +0000 |
| Subject: | Re: overwriting file record | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120463@lists.php.net to get a copy of this message | ||
Thanks!!
But would this work if I was to add / remove one character from the record
(such as to comment out or uncomment a record)? [I am changing the record
length!]
/dl
----- Original Message -----
From: "Warren Vail" <warren@vailtech.net>
To: "DoL" <dwylau@netvigator.com>; <php-general@lists.php.net>
Sent: Friday, October 18, 2002 1:17 PM
Subject: RE: [PHP] overwriting file record
> Sure, try;
>
> $fp=fopen($filename,"r+");
> fseek($fp, $recordstartoffset, SEEK_SET);
> fwrite($fp,$string,strlen($string));
> fclose($fp);
>
> This should work, (haven't tried it lately)
>
> You will want to make sure your string is the right length, and calculate
> the recordstartoffset carefully. You may also want to consider opening
the
> file with the binary safe mode (add a "b" to the mode), especially if your
> server is running under windows. I would also recommend you add some
error
> checking on the write.
>
> hope this gets you where you want to go.
>
> Warren Vail
>
> -----Original Message-----
> From: DoL [mailto:dwylau@netvigator.com]
> Sent: Thursday, October 17, 2002 9:40 PM
> To: php-general@lists.php.net
> Subject: [PHP] overwriting file record
>
>
> Hi All
>
> Is there a smarter way to update a file record instead of moving all
records
> to a new temp file and rename it back afterwards?
>
>
> Many Thanks
> /dl
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>