Re: [PHP4BETA] re:Incremnting a number in a file
| From: | Joseph H Blythe | Date: | Fri, 04 Feb 2000 07:06:47 +0000 |
| Subject: | Re: [PHP4BETA] re:Incremnting a number in a file | ||
| References: | 1 2 3 4 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-9789@lists.php.net to get a copy of this message | ||
Evan Klinger wrote:
> Before you write the new value (after you increment) you need to
> rewind() the file pointer so it points at the beginning of the file
> again and thus will write over the old value. I think this is what
> you're asking.
> --
>
> ev
>
Hey Success! This does what I wanted
<?php
$tdata = "/tmp/txndata";
%fo = fopen("$tdata","r+");
$fr = fread($fo, filesize($tdata));
$fi = $fr+1;
rewind($fo);
$fw = fwrite($fo,$fi);
fclose($fo);
echo "Number = $fr";
?>
thanks again
Joseph H Blythe
Boldweb Internet / Binary Logic
257 Churchill Road Prospect,
Adelaide South Australia 5082
PH: 08 8342 0022
FAX: 08 8342 0155
mailto:webdevel@binarylogic.com.au