yes,I think this is the script you're looking for.
However,This script requires you to have lcnt.txt existing at the time this script 
runs.

<?php
$cfile = fopen("lcnt.txt", 'r+');
$lcnt = @fgets($cfile,10);
rewind($cfile);
fwrite ($cfile,++$lcnt);
fclose($cfile);
?>

--
Regards,
Ns_Andy, [EMAIL PROTECTED]
"Lee Herron" <[EMAIL PROTECTED]> wrote in message 
005601c2cce4$48e59350$6501a8c0@bluewebcow">news:005601c2cce4$48e59350$6501a8c0@bluewebcow...
> Okay, so I want to open a file, get a small number from it (less than 3
> digits) then overwrite a new number (incremented the original by 1) and
> close the file.
>
> The goal is to do this in the fastest way possible .. it seems that there
> should be a way of doing this without having to open and close the file
> twice.
>
> I've tried:
> $cfile = fopen("lcnt.txt", 'r+');
> $lcnt = fgets($cfile,10);
>
> This results in $lcnt having a value of 1 (loaded from value within text
> file)
>
> Now, if I increment it:
>
> $nc = $lcnt+1;
>
> then write it back to the file:
>
> $nul = fwrite($cfile, $nc);
>
> It writes starting at where the last read left off -- I want to start at
> zero offset so to overwrite the existing value. I can't find a method for
> resetting the offset pointer without having to close the file and reopen it
> with w+
>
> There must be a simpler way to do this ...
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to